Inist-CNRS / node-csv-string

CSV Strings & Streams for Javascript since 2012
Other
86 stars 18 forks source link

Support CSV headers #39

Closed uladkasach closed 2 years ago

uladkasach commented 4 years ago

I love the approach you guys have taken with mimicking the JSON api.

Do you guys have an option to support using the first row of the input as a "header" and having parse return an array of objects instead of an array of arrays?

e.g.:

a,b,c
1,2,3
4,5,6

would return

[
{ a: 1, b: 2, c: 3 },
{ a: 4, b: 5, c: 6 }
]
touv commented 4 years ago

No yet, you have to write your own helper see #14 I don't remember why, perhaps to have a very basic behavior

uladkasach commented 4 years ago

Would you guys be open to someone contributing that behavior? Potentially, with an "option" to look for a header?

touv commented 4 years ago

Yes it's open, you can make a PR for a new option or a new function. You just have to take care not to change the current API, not to break the unit tests and to check the performance impact.

see https://github.com/Inist-CNRS/node-csv-string#contribution