aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2022-03-19 21:48:07 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2022-03-19 21:48:07 -0400
commita6e765da9b4da8cf9ddedcbaeb29fe5dca5df263 (patch)
tree39a2e5d06c16d048e9618e1170e3b6304fbade2e /README.md
parente67f4551479264125a641b955523d95e192b6d44 (diff)
parentf5fb17e5a64b215644bc104f099dad8c2f10c37d (diff)
Update upstream source from tag 'upstream/2.9.0'
Update to upstream version '2.9.0' with Debian dir 41b8f9c552bbf25b076de11901d6f615d684366f
Diffstat (limited to 'README.md')
-rw-r--r--README.md16
1 files changed, 14 insertions, 2 deletions
diff --git a/README.md b/README.md
index faf983a..ceb54f6 100644
--- a/README.md
+++ b/README.md
@@ -249,7 +249,7 @@ ods.formula('A', 2)
csv = Roo::CSV.new("mycsv.csv")
```
-Because Roo uses the [standard CSV library](), you can use options available to that library to parse csv files. You can pass options using the ``csv_options`` key.
+Because Roo uses the standard CSV library, you can use options available to that library to parse csv files. You can pass options using the ``csv_options`` key.
For instance, you can load tab-delimited files (``.tsv``), and you can use a particular encoding when opening the file.
@@ -262,6 +262,18 @@ csv = Roo::CSV.new("mytsv.tsv", csv_options: {col_sep: "\t"})
csv = Roo::CSV.new("mycsv.csv", csv_options: {encoding: Encoding::ISO_8859_1})
```
+You can also open csv files through the Roo::Spreadsheet class (useful if you accept both CSV and Excel types from a user file upload, for example).
+
+```ruby
+# Load a spreadsheet from a file path
+# Roo figures out the right parser based on file extension
+spreadsheet = Roo::Spreadsheet.open(csv_or_xlsx_file)
+
+# Load a csv and auto-strip the BOM (byte order mark)
+# csv files saved from MS Excel typically have the BOM marker at the beginning of the file
+spreadsheet = Roo::Spreadsheet.open("mycsv.csv", { csv_options: { encoding: 'bom|utf-8' } })
+```
+
## Upgrading from Roo 1.13.x
If you use ``.xls`` or Google spreadsheets, you will need to install ``roo-xls`` or ``roo-google`` to continue using that functionality.
@@ -271,7 +283,7 @@ Roo's public methods have stayed relatively consistent between 1.13.x and 2.0.0,
## Contributing
### Features
-1. Fork it ( https://github.com/[my-github-username]/roo/fork )
+1. Fork it ( https://github.com/roo-rb/roo/fork )
2. Install it (`bundle install --with local_development`)
3. Create your feature branch (`git checkout -b my-new-feature`)
4. Commit your changes (`git commit -am 'My new feature'`)