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

ASP.NETC#

Avatar of undefined
Last Comment
sbornstein2

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
mankowitz

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
kaufmed

sbornstein2

ASKER
thanks
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes