FileHelpers: Optional fields in unquoted CSV files

I use FileHelpers to import data from a CSV file. The problem is that some versions of the CSV file have more fields than others.

As such, I marked fields that are sometimes missing as optional, but this doesn't seem to work, instead of just ignoring when fields are missing (which seems to be all right), it also always breaks the last character from the last present fields.

For instance...

  • a string containing "ABC, DEF, GHI" (without quotes) imports as "ABC", "DEF" and "GHI"
  • a string containing "ABC, DEF" (again without quotes) imports both "ABC" and "DE"

My recording format is defined as follows:

[DelimitedRecord(@",")] public class RecordFormat { [FieldTrim(TrimMode.Both)] public String FirstValue; [FieldTrim(TrimMode.Both)] public String SecondValue; [FieldOptional] [FieldTrim(TrimMode.Both)] public String OptionalValue; } 

Can anyone say what I am missing?

Thanks.

+4
source share
1 answer

Looks like a bug that seems to be fixed in the latest version 2.9.9

See the link http://www.filehelpers.com/forums/

+1
source

Source: https://habr.com/ru/post/1413212/


All Articles