Created
April 22, 2018 17:41
-
-
Save supremebeing7/c027599ceff6a536e6b378dcb3e19782 to your computer and use it in GitHub Desktop.
roo gem parse issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'roo' | |
csv = Roo::Spreadsheet.open("sample.csv") | |
csv.parse | |
# => [["row1col1", "row1col2", "row1col3"], | |
# ["row2col1", "row2col2", "row2col3"], | |
# ["row3col1", "row3col2", "row3col3"]] | |
csv.parse(headers: true) | |
# => [{"header1"=>"header1", "header2"=>"header2", "header3"=>"header3"}, | |
# {"header1"=>"row1col1", "header2"=>"row1col2", "header3"=>"row1col3"}, | |
# {"header1"=>"row2col1", "header2"=>"row2col2", "header3"=>"row2col3"}, | |
# {"header1"=>"row3col1", "header2"=>"row3col2", "header3"=>"row3col3"}] | |
csv.to_a | |
# => [["header1", "header2", "header3"], | |
# ["row1col1", "row1col2", "row1col3"], | |
# ["row2col1", "row2col2", "row2col3"], | |
# ["row3col1", "row3col2", "row3col3"]] | |
csv.row(1) | |
# => ["header1", "header2", "header3"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
header1 | header2 | header3 | |
---|---|---|---|
row1col1 | row1col2 | row1col3 | |
row2col1 | row2col2 | row2col3 | |
row3col1 | row3col2 | row3col3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment