ben-strasser / fast-cpp-csv-parser

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

Process a CSV where each line has varying headers #112

Closed deathwishdave closed 3 years ago

deathwishdave commented 3 years ago

Hello, I am trying to process a common format for weather data, the EPW file. Here is an example

The first 8 lines contain varying csv data, each line with its own headers.

Can this be processed with this library please?

ben-strasser commented 3 years ago

Hi,

What you can do is create a CSVReader, then call 8 times next_line on it. This will give you the first eight lines unmodified. Next you call set_header to give the column names (which are only used in the error messages), and then read_row will work for the rest.

This setup will work, but it is kind of a hack. I am uncertain whether you gain enough using this library for this application to justify the extra dependency.

Best Regards

Ben Strasser