1

I am working on a File Parser using StreamReader on MemoryStream which in turn is created from a csv file. We have our own file parser to validate the file. I know there are now many solutions available but this is something I cannot avoid at this moment.

It works very smoothly except couple of scenarios 1) User can prefer using Alt+Enter to enter something on one of the comments columns. StreamReader.ReadLine() takes that as a new row. 2) Deleting data instead of deleting rows makes that an empty row and reader validates them as well.

One of the solution I found for Issue 2 was to use TextFieldParser of Microsoft.VisualBasic-

var parser = new TextFieldParser(new StringReader(line))
var readFields = parser.ReadFields();

but this again doesn't solves Issue 1. I am looking for something that will solve both the problems.

Any help is appreciated.

MethodMan
  • 18,625
  • 6
  • 34
  • 52
Raj
  • 227
  • 5
  • 13
  • [Related](http://stackoverflow.com/questions/1179157/how-do-i-handle-line-breaks-in-a-csv-file-using-c). TextFieldParser should work, assuming your CSV files surround data with line breaks in quotes (and escape existing quotes). – Kade Oct 24 '16 at 19:24
  • Maybe scan the text for Environment.NewLine would assist in the first issue ? – Greg Trevellick Oct 24 '16 at 20:20

0 Answers0