Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Excel中编辑后在CSV文件中插入不需要的逗号_C#_Excel_Csv - Fatal编程技术网

C# 在Excel中编辑后在CSV文件中插入不需要的逗号

C# 在Excel中编辑后在CSV文件中插入不需要的逗号,c#,excel,csv,C#,Excel,Csv,我有一个csv文件要在VisualStudio中使用 示例文件数据 Address,included City,State,Country,Zip Boston,MA,US,02120 Customer,included Name,Id a,1 现在,如果我在Excel中打开此文件以更改zip值,则新保存的文件将为 Address,included,, City,State,Country,Zip Boston,MA,US,02119 ,,, Customer,included,, Name

我有一个csv文件要在VisualStudio中使用

示例文件数据

Address,included
City,State,Country,Zip
Boston,MA,US,02120

Customer,included
Name,Id
a,1
现在,如果我在Excel中打开此文件以更改zip值,则新保存的文件将为

Address,included,,
City,State,Country,Zip
Boston,MA,US,02119
,,,
Customer,included,,
Name,Id,,
a,1,,
也就是说,它将文件转换为使每行的列数等于具有最大列数的行数。 在这种情况下是4。代表一个城市、州、国家、地区

我的问题是如何避免不必要的逗号插入,。 我通过使用相同的文件名替换文件来保存更改。以CSV逗号分隔格式

在保存之前,它警告我

"Test.csv may contain features that are not compatible with CSV (Comma delimited.)"

如何避免不必要的逗号插入?编辑后,是否有其他格式的文件需要保存?

据我所知,在excel中不能这样做


在记事本、记事本++或任何其他文本编辑器中打开文件。在其中编辑它,然后保存它。

我可以在Visual Studio中自己进行编辑。但是,如果能够在Excel中进行编辑,那么随着列数变得越来越大、越来越复杂,编辑工作将变得更加容易。