0

Hi I have the following CSV file:

COMMADDMMYY HHMM HEAD LINE VAT TLR SCHEDRECON
HEAD, TEST, JSHO, 5010011090036, B05460003086, 250501, 260501, 0000, Z929901, , , , , , , , , , , , , , , ,
LINE, 1, , , 14, 5010012143560, , , , , , ,
LINE, 9, , , 35, 5010012269499, , , , , , ,
RECON, TEST, JSHO, B05460003086, 9
HEAD, TEST, JSHO, 5010011090052, B05460005086, 250501, 260501, 0000, Z929901, , , , , , , , , , , , , , , ,
LINE, 1, , , 105, 5010012116311, , , , , , ,
LINE, 7, , , 45, 5010012269499, , , , , , ,
RECON, TEST, JSHO, B05460005086, 7
EOF, 00000022

I would like to use LinqToCSV to parse this, but do all rows have to be the same for LinqToCSV to work?

The columns are different in some rows, Im wondering if its possible to maybe read one line at a time or something?

Thanks Neil

Neil Hosey
  • 465
  • 6
  • 23
  • A CSV is always assumed to be rows containing the same columns.If your file has different columns per row then its no longer a CSV and LinqToCSV is not going to help. What are you trying to parse the information into? – CathalMF Jul 23 '14 at 12:50
  • thanks for the reply. So as you can probably guess, its an order file containing several orders.. so I Need to convert the HEAD and LINE's lines of the file into an Order object, with a List part of the order object. – Neil Hosey Jul 23 '14 at 13:19
  • i can easily do this manually using ordinary linq, but I was looking for a better solutions, as i will need to generate this format aswell unfortunately, as well as read it. – Neil Hosey Jul 23 '14 at 13:20
  • 1
    Since its a custom format you are going to have to design your own way of reading and generating it. – CathalMF Jul 23 '14 at 13:35
  • hmm ok, i was hoping there was some lib available for it, but thanks. – Neil Hosey Jul 24 '14 at 09:13

0 Answers0