jehugaleahsa / FlatFiles

Reads and writes CSV, fixed-length and other flat file formats with a focus on schema definition, configuration and speed.
The Unlicense
357 stars 64 forks source link

Provide option for skipping header rows in fixedlength files. #13

Closed freein closed 8 years ago

freein commented 8 years ago

In a project I needed to skip the first row of a file and I found no such functionality in this library.

jehugaleahsa commented 8 years ago

Thanks for your pull request. It actually reminded me that I wanted to support "skipping" records a long time ago. You'll find in the latest code/NuGet package that there is now a Skip method on the SeparateValueReader and FixedLengthReader classes.

I am still deciding how I want to handle skipping leading rows in fixed length files. You provided a more flexible solution, allowing an arbitrary number of rows to be skipped up-front. Is this because you needed to skip more than one row or just to be more generic? Originally, I thought it'd be nice to have an IsFirstRecordSchema property, similar to the SeparatedValueOptions class. In retrospect, I would never use the first row to determine the schema for a fixed-length file, so "schema" isn't quite the right word. So my next thought is IsFirstRecordHeader.

freein commented 8 years ago

Thanks for adding the Skip method. It can be useful.

In my case it is sufficient to skip one row, however I wanted to make it more generic. I don't want to use the first row as header either. In my case it was only garbage. About garbage, sometimes there can be garbage in the n last rows of a fixed-length file as well.