1
votes

I'm using the LumenWorks CsvReader to parse a file with the following structure.

heading1,heading2,heading3
data1,data2,data3,data4,data5

The code detects that I've got three fields per row because I've got three headings. It happily allows me to parse the first row and retrieve data1, data2, and data3, but i can't access data4 or data5. At the very least, I'd like to be able to detect additional fields in the data rows. Does anyone know if this is possible?

Thanks!

2
what code are you using to hide the other two fields?RhysW
I'm not using any code to hide the fields. I'm trying to find a way to read them and I can't.Jordan

2 Answers

2
votes

It does this because it uses the first row to know how many columns your file has. If you change the first row to "heading1,heading2,heading3,," it will work as expected.

0
votes

I expect that you won't be able to read the data in those fields. Rather, I expect that an error is being raised and you're not seeing it. This would at least allow you to detect that those other fields exist in the data.

Try setting the DefaultParseErrorAction enum property so that you ensure you're seeing any errors being raised. I would have expected the scenario you describe to trigger a MalformedCsvException (if you have set the DefaultParseErrorAction = ParseErrorAction.ThrowException). You could also set DefaultParseErrorAction = ParseErrorAction.RaiseEvent and then attach an event handler to the ParseError event. Finally, you should be able to just check if the ParseErrorFlag is true after each record.

HTH