How to handle nested delimiter character in fields in CsvHelper?

52 Views Asked by At

I'm unable to create a mapping / configuration for the following sample data:

W001;MFS;4262;EMFS;{MFS;W001;;};109;11;"A";["TEID","Int "]

Which should result in something like:

  1. W001
  2. MFS
  3. 4262
  4. EMFS
  5. {MFS;W001;;}
  6. 109
  7. ...

Every time I try, the value for field 5 is {MFS, because the nested semicolon is recognized as the delimiter character. Also setting the quote character is not an option, in that case.

Or an input like this:

MFS1;W001;8;STSO;TL1B;;[{"ON00000008";;DP;"LC00420017";{SO;1;;;;;;};[]}]

Where [{"ON00000008";;DP;"LC00420017";{SO;1;;;;;;};[]}] should be treated as a single field.

Is this possible at all with CsvHelper or are there other recommendations?

1

There are 1 best solutions below

0
whaeussler On

The comment from Boris Maslennikov answers the question. My data is invalid CSV and CsvHelper is not the right tool to parse this kind of data. Thank you Boris Maslennikov and dbc for your comments and help!