Suppose I have this CSV file :
NAME,ADDRESS,DATE
\"Eko S. Wibowo\", \"Tamanan, Banguntapan, Bantul, DIY\", \"6/27/1979\"
I would like like
I've done this with my own method. It simply counts the amout of " and ' characters.
Improve this to your needs.
public List SplitCsvLine(string s) {
int i;
int a = 0;
int count = 0;
List str = new List();
for (i = 0; i < s.Length; i++) {
switch (s[i]) {
case ',':
if ((count & 1) == 0) {
str.Add(s.Substring(a, i - a));
a = i + 1;
}
break;
case '"':
case '\'': count++; break;
}
}
str.Add(s.Substring(a));
return str;
}