如何使用java从csv文件中删除列?

时间:2021-08-14 19:26:06

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文件中删除一个列就不会有简单的函数调用。要删除列,您需要执行几个步骤。

  1. Open the existing CSV file, f0
  2. 打开现有的CSV文件f0

  3. Create a new CSV file f1
  4. 创建一个新的CSV文件f1

  5. Loop through f0. For each line in f0 write it to f1, excluding only the column you don't want.
  6. 循环通过f0。对于f0中的每一行,将其写入f1,仅排除您不想要的列。

  7. Once you're done reading f0, close and delete f0.
  8. 读完f0后,关闭并删除f0。

  9. Rename f1 to f0.
  10. 将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文件中删除一个列就不会有简单的函数调用。要删除列,您需要执行几个步骤。

  1. Open the existing CSV file, f0
  2. 打开现有的CSV文件f0

  3. Create a new CSV file f1
  4. 创建一个新的CSV文件f1

  5. Loop through f0. For each line in f0 write it to f1, excluding only the column you don't want.
  6. 循环通过f0。对于f0中的每一行,将其写入f1,仅排除您不想要的列。

  7. Once you're done reading f0, close and delete f0.
  8. 读完f0后,关闭并删除f0。

  9. Rename f1 to f0.
  10. 将f1重命名为f0。