Gerald Bauer
2018-08-21 14:24:53 UTC
Hello,
I've started to put together a new library / gem, that is, csvreader [1] -
that lets you read tabular data in the comma-separated values (csv) format
the right way :-), that is, uses best practices such as
- stripping / trimming leading and trailing spaces,
- skipping comments and blank lines,
- "fixes" quote errors and more
all out-of-the-box with zero-configuration.
And, thus, fixes some major bugs in the (old) standard csv library
with a purpose-built parser (instead of a supposed "faster" split(",") kludge).
Happy data wrangling with ruby. Cheers. Prost.
[1] https://github.com/csv11/csvreader
PS: Usage sample in Ruby code:
line = "1,2,3"
values = CsvReader.parse_line( line )
pp values
# => ["1","2","3"]
or use the convenience helpers:
txt <<=TXT
1,2,3
4,5,6
TXT
records = CsvReader.parse( txt )
pp records
# => [["1","2","3"],
# ["5","6","7"]]
Unsubscribe: <mailto:ruby-talk-***@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
I've started to put together a new library / gem, that is, csvreader [1] -
that lets you read tabular data in the comma-separated values (csv) format
the right way :-), that is, uses best practices such as
- stripping / trimming leading and trailing spaces,
- skipping comments and blank lines,
- "fixes" quote errors and more
all out-of-the-box with zero-configuration.
And, thus, fixes some major bugs in the (old) standard csv library
with a purpose-built parser (instead of a supposed "faster" split(",") kludge).
Happy data wrangling with ruby. Cheers. Prost.
[1] https://github.com/csv11/csvreader
PS: Usage sample in Ruby code:
line = "1,2,3"
values = CsvReader.parse_line( line )
pp values
# => ["1","2","3"]
or use the convenience helpers:
txt <<=TXT
1,2,3
4,5,6
TXT
records = CsvReader.parse( txt )
pp records
# => [["1","2","3"],
# ["5","6","7"]]
Unsubscribe: <mailto:ruby-talk-***@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>