Java- CSV / Delete column in csv file, the answer in this link is not clear can anyone pls suggest me how to do it.
csv文件中的Java-CSV / Delete列,此链接中的答案不清楚任何人都可以建议我如何做到这一点。
1 个解决方案
#1
2
Given what a CSV file is, there isn't going to be an easy function call to simply delete a column from the CSV file. To delete a column, you'll need to do a few steps.
鉴于CSV文件是什么,只需从CSV文件中删除一个列就不会有简单的函数调用。要删除列,您需要执行几个步骤。
- Open the existing CSV file,
f0
- Create a new CSV file
f1
- Loop through
f0
. For each line inf0
write it tof1
, excluding only the column you don't want. - Once you're done reading
f0
, close and deletef0
. - Rename
f1
tof0
.
打开现有的CSV文件f0
创建一个新的CSV文件f1
循环通过f0。对于f0中的每一行,将其写入f1,仅排除您不想要的列。
读完f0后,关闭并删除f0。
将f1重命名为f0。
#1
2
Given what a CSV file is, there isn't going to be an easy function call to simply delete a column from the CSV file. To delete a column, you'll need to do a few steps.
鉴于CSV文件是什么,只需从CSV文件中删除一个列就不会有简单的函数调用。要删除列,您需要执行几个步骤。
- Open the existing CSV file,
f0
- Create a new CSV file
f1
- Loop through
f0
. For each line inf0
write it tof1
, excluding only the column you don't want. - Once you're done reading
f0
, close and deletef0
. - Rename
f1
tof0
.
打开现有的CSV文件f0
创建一个新的CSV文件f1
循环通过f0。对于f0中的每一行,将其写入f1,仅排除您不想要的列。
读完f0后,关闭并删除f0。
将f1重命名为f0。