我有一个奇怪的问题。
我尝试读取 csv 文件以进行数据迁移。这就是文件的外观(其 UTF8 格式)
"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"
如您所见,它是逗号分隔的。
我使用流式阅读器阅读它:
System.IO.StreamReader file = new System.IO.StreamReader(documentFilePath, Encoding.UTF8);
while ((line = file.ReadLine()) != null)
{
//perform the transformation
}
我已经做了一百万次没有问题。但是,当读取行时,它们突然像这样出现(从调试监视复制):
"\"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\""
所有这些反斜杠来自哪里?我是不是读错了文件。我怎样才能防止这种情况?因为它破坏了我对数据的进一步处理。