I have an odd problem.
I try to read a csv file for a datamigration. This is how the file looks (its UTF8 formatted)
"MIGRATIONID","ACCOUNTID","MIGRACCOUNTID","CONFIGID","MEDIUMID","PRIMCLASSID","SECCLASSID","SALESCODE","CONTENT","REGELNR","LIST_ATTRIBUTES","PACKAGE_TYPE","VERWIJSADVERTENTIE","NIET_PUBLICEREN"
"ITM-0015-0163","62222532","ACT-0000-4755","61635591","TGP","TG_P_GV_01","","TG_Print_GV","%NAME%|%STREETNAME%|%HOUSENUMBER%|%HOUSENUMBEREXT%||%POSTALCODE%|%LOCALITY%|%AREACODE%|%CONNECTIONNUMBER%|%URL%|%EMAIL%||%COMMERCIAL%||||||%PRODNR%","10","","","","FALSE"
"ITM-0015-0172","62222140","ACT-0000-4779","61636356","TGP","TG_P_GV_01","","TG_Print_GV","%NAME%|%STREETNAME%|%HOUSENUMBER%|%HOUSENUMBEREXT%||%POSTALCODE%|%LOCALITY%|%AREACODE%|%CONNECTIONNUMBER%|%URL%|%EMAIL%||%COMMERCIAL%||||||%PRODNR%","10","","","","FALSE"
As you can see, it is comma separated.
I read it using a streamreader:
System.IO.StreamReader file = new System.IO.StreamReader(documentFilePath, Encoding.UTF8);
while ((line = file.ReadLine()) != null)
{
//perform the transformation
}
I have done this a million times without problems. However, when the rows are read, they suddenly turn up like this (copied from the debug watch):
"\"ITM-0015-0163\",\"62222532\",\"ACT-0000-4755\",\"61635591\",\"TGP\",\"TG_P_GV_01\",\"\",\"TG_Print_GV\",\"%NAME%|%STREETNAME%|%HOUSENUMBER%|%HOUSENUMBEREXT%||%POSTALCODE%|%LOCALITY%|%AREACODE%|%CONNECTIONNUMBER%|%URL%|%EMAIL%||%COMMERCIAL%||||||%PRODNR%\",\"10\",\"\",\"\",\"\",\"FALSE\""
Where do all these backslashes come from? Am i reading the file wrong. How can i prevent this? Because it wrecks up my further processing of the data.
The debugger just shows the value like it would appear in a literal in code (note that it’s surrounded by quotation marks, too). You can click the little magnifying glass to open a text-only view which will not put backslashes there.
If you doubt this you can just write the text you read to the console to verify it.