Kasper,

I think this is somewhat close to another thing I am describing here: https://github.com/svenvc/NeoCSV/issues/20

The problem with extending NeoCSV endlessly is that some of the things we need with "real-life" CSV files is the fact that they are not CSV files at all, so it is hard to tell if it is a good idea to litter NeoCSV with methods for edge cases that have literally to do with the fact that part of our files are not CSV at all...

I somehow have the feeling some of what we need is a subclass of Stream that knows about constraints like "a line-break is only the end of a record if it is not part of a quoted field". So I am somewhat torn between wanting that stuff in NeoCSV and not wanting to mix csv parsing with handling of stupid ideas people have when exporting data in some CSV-like file.

Maybe it is a good idea to collect a few concepts that have been mentioned in these threads:

Of course this all doesn't mean I am not a fan of NeoCSV. It is well-written, works very well for "real" CSV and performs very well for my use cases. Most of the things we are talking about here are problems that arise when a CSV-file is not a CSV-file...


Joachim




Am 22.01.21 um 07:42 schrieb Kasper Osterbye:
As it happened, I ran into the exact same scenario as Joachim just the other day,
that is, the external provider of my csv had added some new columns. In my case
manifested itself in an error that an integer field was not an integer (because new
columns were added in the middle).

Reading through this whole thread leaves me with the feeling that no matter what Sven
adds, there is still a risk for error. Nevertheless, my suggestion would be to add a��
functionality to #skipHeaders, or make a sister method:��
#assertAndSkipHeaders: numberOfColumns onFailDo: aBlock given the actual number of headers
That would give me a way to handle the error up front.��

This will only be interesting if your data has headers of cause.

Thanks for NeoCSV which I use all the time!

Best,

Kasper��


-- 
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:jtuchel@objektfabrik.de
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1