ben-strasser / fast-cpp-csv-parser

fast-cpp-csv-parser
BSD 3-Clause "New" or "Revised" License
2.15k stars 440 forks source link

Support to skip N header rows #22

Closed breznak closed 8 years ago

breznak commented 8 years ago

Hi,

is there a way to skip arbitrary N rows of the header? Our CSV files look like this:

colName1, colName2, ...
meta1,meta2
comment1, comment2
data1-1,data2-1
data1-2,data2-2
....

Is there a way to parse this? I'd call set_header("colName1", "colName2"); then something like: skipToRow(4), ...read data

If not, would you consider implementing that? Thank you,

ben-strasser commented 8 years ago

Hi,

does the recent commit that adds CSVReader::next_line help?

There is a mechanism to skip comment lines. However, you need to be able to tell by only looking at the line whether it is a comment, i.e., a rule similar to: "The first 4 lines are comments" does not work with that mechanism because you do not know the line number.

Best Regard Ben Strasser

On 04/29/2016 04:23 PM, breznak wrote:

Hi,

is there a way to skip arbitrary |N| rows of the header? Our CSV files look like this:

|colName1, colName2, ... meta1,meta2 comment1, comment2 data1-1,data2-1 data1-2,data2-2 .... |

Is there a way to parse this? I'd call |set_header("colName1", "colName2")|; then something like: |skipToRow(4)|, ...read data

If not, would you consider implementing that? Thank you,

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/ben-strasser/fast-cpp-csv-parser/issues/22

breznak commented 8 years ago

Works like a charm! :clap:

This is exactly the functionality we needed. Thank you very much Ben.

(I love open source, took 16 mins from reported bug to fix) :wink:

Fixed in 646bbe5