所以我读了一个大的CSV文件,它可能看起来像
"Intelligent Mail barcode","Sack and Pa","Opt. Endorsement Line","Label ","NAME","COMPANY","DELADDR","CITY","ST","ZIP"
"xxxxxxxxxxxxxxxxxxxxxxxxx","T1 P1","******AUTO**MIXED AADC 403","xxxx","xxxxxxxx","xxxxxxxxxxxxxxxx","xxxxxxxx","xxxxx","xxxx","xxxxx"
"xxxxxxxxxxxxxxxxxxxxxxxxx","T1 P1","******AUTO**MIXED AADC 403","xxxx","xxxxxxxxxx","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","xxxxxx","xxxxx","xx","xxxxx"
我想在这种情况下删除前4列。所以智能邮件,Sack和Pa,选择。支持,Label1将被忽略,与它们相关的数据也将被忽略或空白。
所以输出就像
"NAME","COMPANY","DELADDR","CITY","ST","ZIP"
"xxxxxxxx","xxxxxxxxxxxxxxxx","xxxxxxxx","xxxxx","xxxx","xxxxx"
"xxxxxxxxxx","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","xxxxxx","xxxxx","xx","xxxxx"
我怎样才能做到这一点?寻找最简单的方法。
以下是我目前读取CSV的方式:
using (StreamReader reader = new StreamReader(fileSaveLocation))
{
string line;
header = reader.ReadLine();
while ((line = reader.ReadLine()) != null)
{
sb.Append(line);
sb.Append(Environment.NewLine);
}
}