praveen1981
asked on
Split CSV File
Hi
I have the data as following in CSV File
vikram,vijay,hai,"nice,100 " boy, "good,200"
now how can i split this data , can you please suggest.
I have the data as following in CSV File
vikram,vijay,hai,"nice,100
now how can i split this data , can you please suggest.
ASKER
Hi
I want to do this in c#.net code
can u please suggest.
I want to do this in c#.net code
can u please suggest.
have you tried this , this is C#.net code
StreamReader sr = new StreamReader("file.csv");
string inputLine = "";
String[] values = null;
while ((inputLine = input.ReadLine()) != null)
{
values = inputLine.Split(";");
}
input.Close();
StreamReader sr = new StreamReader("file.csv");
string inputLine = "";
String[] values = null;
while ((inputLine = input.ReadLine()) != null)
{
values = inputLine.Split(";");
}
input.Close();
ASKER
Hi
I have tried the above which is not working.
I have tried the above which is not working.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This is an improperly formed comma separated file.
Use TextFieldParser.
ASKER
Excellent, it solved the problem,
Many Thanks.
Many Thanks.
string inputLine = "";
String[] values = null;
while ((inputLine = input.ReadLine()) != null)
{
values = inputLine.Split(";");
}
input.Close();
Loops over all the lines in the text file, and each time you have an string array with all the values for that line.