Search code examples
javacsvfileutils

Java- CSV / Delete column in csv file


I try to delete a column in csv file in Java.

for example, I have this csv file

ID   name1   name2   name3
1    hello   hell    hel
2    try     tr      t
3    browser bro     br

and I want the after the next operation: (delete csvFile, 2) it will be:

ID   name1   name3
1    hello   hel
2    try     t
3    browser br

I found only operations that invlove rows and not column.


Solution

  • The only way to delete a column in a CSV file is to remove the header and the information of this column in the whole file, that is for each row of the file. Even if you use a third party library it will do this internally.