Im trying to split a string into sub parts to pass into a linq database, but ive come up with a problem. The file is a .csv file so its split up by commas example :
1,Ms,Aleshia,Tomkiewicz,14 Taylor St,St. Stephens Ward,Kent,CT2 7PP,01835-703597,atomkiewicz@hotmail.com.
However some of the data contains commas in the data field like a county/address is split up with a comma however i dont want it to split i want it to keep that data all together for example address: London,Wimbledon.
im using this code currently to do the chopping:
public static List<string> ReturnCSVFromWeb(string url)
{
System.Net.WebClient client = new WebClient();
string CSVContent = client.DownloadString(url);
List<string> splitted = new List<string>();
string csvFile = CSVContent;
string[] tempStr;
tempStr = csvFile.Split(',','\n');
foreach (string item in tempStr)
{
if (!string.IsNullOrWhiteSpace(item))
{
splitted.Add(item);
}
}
return splitted;
}