CSV.js icon indicating copy to clipboard operation
CSV.js copied to clipboard

Support Definable Row Number for Header

Open jcq opened this issue 10 years ago • 4 comments

I have need for reading CSV files from multiple sources, some of which have multi-row headers (only one of which has actual column headers). It would be nice to be able to tell the parser to ignore the first X rows of a file and/or look for headers at a set row number.

jcq avatar Jul 07 '14 21:07 jcq

Could you supply your own header values using the below?

new CSV(data, { header: ['column 1', 'column 2', 'column 3'...])

I'd be happy to add this feature (or accept a pull request implementing it) if there's more than 1 person requesting it.

CyrusNuevoDia avatar Jul 08 '14 13:07 CyrusNuevoDia

Yes I need this as well. Also how do I parse from a file as streaming read/parse

nraghu99 avatar Oct 15 '14 15:10 nraghu99

@nraghu99 CSV.js can't currently do that.

CyrusNuevoDia avatar Oct 15 '14 22:10 CyrusNuevoDia

Now, a workaround would be to chop the first n lines out of the string before it hits CSV. str = str.substring(str.indexOf( line_delimiter ) + 1); Repeat for how many lines you want to ignore.

NathanSmutz avatar Oct 18 '14 21:10 NathanSmutz