mperdeck/LINQtoCSV

cc.write<> should ignore extraneous data in class

burningbaal opened this issue · 0 comments

Though it seems this project is under-maintained lately, I want to suggest an addition:
Either via a decorator (ie: [CsvColumn(Name = "extra_data", FieldIndex = null)] or, probably better, via the fileDescription (ie: IgnoreExtraClassData = true), extra data in the class should not be written to the file upon cc.write<>

I have a helper class that interprets a string from particular columns to implement a custom sort algorithm (for well position addresses in 96-well microtiter plates, FYI), so in addition to the column data (column header = DestWellId), I had an object called DestWell which properly interpreted the meaning of the string and implemented a comparer method for sorting. However, when I called cc.write<>, it always wrote these DestWell objects as new columns (at the right-side of the file), and it seems there was nothing I could do to avoid it.