From f5fb17e5a64b215644bc104f099dad8c2f10c37d Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sat, 19 Mar 2022 21:47:36 -0400 Subject: New upstream version 2.9.0. --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'README.md') 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'`) -- cgit v1.2.3