Last active
August 29, 2015 14:00
-
-
Save aharpole/11385660 to your computer and use it in GitHub Desktop.
CSV.parse unexpected behavior
This file contains hidden or 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
1.9.3-p545 :002 > headers = "col,is,cool" | |
=> "col,is,cool" | |
1.9.3-p545 :003 > csv = CSV.parse(headers,{headers:true}) | |
=> #<CSV::Table mode:col_or_row row_count:1> | |
1.9.3-p545 :004 > tworows = "#{headers}\nabc,def,ghi" | |
=> "col,is,cool\nabc,def,ghi" | |
1.9.3-p545 :005 > other_csv = CSV.parse(tworows,{headers:true}) | |
=> #<CSV::Table mode:col_or_row row_count:2> | |
1.9.3-p545 :006 > csv.headers | |
=> [] #I expect this to be ["col", "is", "cool"] | |
1.9.3-p545 :007 > other_csv.headers | |
=> ["col", "is", "cool"] #this is what I expect it to be |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment