node-csvtojson icon indicating copy to clipboard operation
node-csvtojson copied to clipboard

Add headerParser option

Open ywaserblat-excelforce opened this issue 4 years ago • 4 comments

Hi there. First of all thank you so much for this package, it's incredibly useful, and I am using it every day at work!

I wanted to ask if it is possible to add an option for headerParser that will accept a function, to be able to do common parsing tasks (e.g. camel-casing, etc), that way one could specify some logic for parsing all headers without the need to provide an array of pre-defined header names. I think this will be a valuable addition. Thank you in advance!

ywaserblat-excelforce avatar Jun 08 '21 15:06 ywaserblat-excelforce

If headers is an Array, why won't you simply use map to parse each header, before you feed the Array into the options Object?

jfoclpf avatar Jan 09 '22 22:01 jfoclpf

I am getting the csv data from a 3rd party API endpoint, and although the request contains the list of columns to be retrieved, I don't always know how exactly the header will be laid out, so my only option is to provide a list of statically-typed headers to override the supplied one. (luckily the csv columns are always in the same order as requested) Thus, an option to pass a parsing function will be super-handy. Many Thanks again for taking the time for my issue!

ywaserblat-excelforce avatar Feb 09 '22 21:02 ywaserblat-excelforce

Hi, even if you're getting the data from a third party, I'd say you can transform it before feeding it into this module.

jfoclpf avatar Mar 21 '22 08:03 jfoclpf