I am trying to parse a CSV file with commas in the data. All fields do not have quotes around them, but SOME of the dollar amounts do when there is a comma in them. So for example the file looks something like this:
0000-0C,Sales-Data Entry,10/31/2016,000000,VJ,Comapny,,312.3
0000-0C,Sales-Data Entry,10/31/2016,000000,VJ,Company,,"1,420.97"
So as you can see there is a comma in the 1,420.97 but it does have quotes around this. Is there a way to reliably read this file?
Here is my code:
var path = @"glid.csv";
TextFieldParser parser = new TextFieldParser(path);
parser.HasFieldsEnclosedInQuotes = true;
parser.SetDelimiters(",");
while (!parser.EndOfData)
{
parser.ReadLine();
fields = parser.ReadFields();
//do something
}
parser.Close();