sbornstein2
asked on
ASP.Net - Easy question CSV read comma
Hello all,
I have the following code and the split is finding the extra comma it looks like in the row like this how do I handle this. File has 9 columns 0-8 Row example:
I have the following code and the split is finding the extra comma it looks like in the row like this how do I handle this. File has 9 columns 0-8 Row example:
[2]: "AE,1,VARIABLE,ID,SD0058,\"Variable appears in dataset, but is not in SDTM standard\",Metadata,Warning,"
Code is:
// create new datatable
DataTable dt = new DataTable();
// get the column header means first line
string[] temp = str[0].Split(',');
// creates columns of gridview as per the header name
foreach (string t in temp)
{
dt.Columns.Add(t, typeof(string));
}
// now retrive the record from second line and add it to datatable
for (int i = 1; i < str.Length; i++)
{
string[] t = str[i].Split(',');
dt.Rows.Add(t);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
https://www.experts-exchange.com/questions/27527330/regular-expression-to-ignore-comma-inside-the-double-quoted-strings-in-CSV-file.html?anchorAnswerId=37440870#a37440870
https://www.experts-exchange.com/questions/26390451/replace-commas-in-the-double-quotes-so-that-I-am-able-to-use-String-Split.html?anchorAnswerId=33395609#a33395609