Reading CSV columns, but taking note of string identifiers
Hi, I have a bit of an issue when reading a CSV file that makes use of string idenfitiers (i.e. all of the column data is wrapped in quotes).
My code is reading out the 36th and 37th column of the csv and replacing the values with new ones..
This works in 99% of cases, but I have noticed that the remaining 1% throws up an error because earlier in the CSV's row a string contains a comma. In most cases this would be fine because the string identifiers would ensure that the comma is not idenfitied as a column seperator.
In my code, the idenfitiers are seeminly ignored and what should be the 36th and 37th row is actually in row 37 and 38 (as it has been pushed by the extra comma).
I need somehow to tell my code that when it identifes the column number, it MUST take in to account the string seperators.
Code
'36' and '37' are passed straight in from the appconfig colindex1 and colindex2
private static void CombineFileColumns(string ocbFileName, string separator, int col1Index, int col2Index)
columns[col1Index].Replace(speechMark, string.Empty),
separator,
columns[col2Index].Replace(speechMark, string.Empty),
I need somehow to build in this string identification - does anyone have any good ideas on how to achieve this??
Many thanks