csvreader - read tabular data in the comma-separated values (csv) format the right way

17 views
Skip to first unread message

Gerald Bauer

unread,
Aug 21, 2018, 10:25:59 AM8/21/18
to www...@googlegroups.com
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"]]
Reply all
Reply to author
Forward
0 new messages