Link to home
Start Free TrialLog in
Avatar of sbornstein2
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:

 
[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);
        }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mankowitz
mankowitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sbornstein2
sbornstein2

ASKER

thanks