This is my CSV file
I am trying to read the data however, instead of showing as four columns, it reds as 6 individual columns. The commas are the issue but I cant figure out how to parse the data properly. Could someone help me figure this out?
Code:
using(StreamReader sr = new StreamReader(file, true)) {
sr.ReadLine();
while ((line = sr.ReadLine()) != null) {
if (line.Contains("\"")) {
line = String.Format("\"{0}\"", line.Replace("\"", "\"\""));
}
data = line.Split(delims, StringSplitOptions.None);
username = data[0].ToString().Trim();
profile = data[1].ToString().Trim();
string[] marketvalues = data[2].ToString().Split(',');
default_market = data[3].ToString().Trim();
}
}
Raw CSV
Username,Profile,Markets,Default Market
kw044352,,"Kitts,Test,Vincent",