cfsimplicity / spreadsheet-cfml

Standalone library for working with spreadsheets and CSV in CFML
MIT License
126 stars 35 forks source link

Reading CSV: Add feature to skip N rows at the top of the file #337

Closed bdw429s closed 10 months ago

bdw429s commented 10 months ago

I'm working some pricing files from Carnival Cruise and they all have some dumb extra sort of "comment" line at the top of every CSV file that simply needs skipped. The NEXT line are the headers.

Ex:

Date:  10302023  Time: 02:01 EST VERSION
Category,Meta,Category description,
FA,INTERIOR,FAMILY INTERIOR,
HA,INTERIOR,HAVANA INTERIOR,
TA,INTERIOR,HAVANA INTERIOR,
4S,INTERIOR,SPA INTERIOR,
4T,INTERIOR,SPA INTERIOR,
4A,INTERIOR,STANDARD INTERIOR,
4B,INTERIOR,STANDARD INTERIOR,
4C,INTERIOR,STANDARD INTERIOR,
4D,INTERIOR,STANDARD INTERIOR,
4E,INTERIOR,STANDARD INTERIOR,

I would suggest some feature to skip an arbitrary number of lines at the start of the file which would boil down to just calling iterator.next() that many times to skip.

cfsimplicity commented 10 months ago

https://github.com/cfsimplicity/spreadsheet-cfml/blob/e0b0f38d72e489de3fb3037f80cd7f14f7723f7b/test/specs/readCsv.cfm#L95