从csv文件中特定列下的行中删除值 [英] Remove values from rows under specific columns in csv file
本文介绍了从csv文件中特定列下的行中删除值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在尝试从CSV文件中特定列下的行中删除特定值.
I'm currently trying to remove specific values from rows under specific columns in a CSV-file.
什么是最好的方法?
是在代码中使用XSLT映射文件还是仅通过代码执行此操作?(使用c#)
Is it to use a XSLT map file in the code or doing this only by code? (Using c#)
我想做的是这样:
操作之前:
id, name, email, phoneNumber, dob
1,John Doe,JohnDoe@mail.com,123456789,1988-08-08
2,Jane Doe,JaneDoe@mail.com,987654321,1987-07-07
操作后:
id, name, email, phoneNumber, dob
1,John Doe,,,1988-08-08
2,Jane Doe,,,1987-07-07
如您所见,电子邮件"和电话号码"消失了
As you can see "email" and "phoneNumber" is gone
推荐答案
您可以使用不带任何库的C#来分隔和联合csv字符串.比使用XLST更容易.作为示例:
You can use C# without any libs to separate and joint csv strings. it's easier than use XLST. As sample:
String csv = "1,John Doe,JohnDoe@mail.com,123456789,1988-08-08";
String[] csvList = csv.Split(',');
csvList[2] = "";
csvList[3] = "";
csv = String.Join(",", csvList);
这篇关于从csv文件中特定列下的行中删除值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文