在删除Java中的列后,如何更换CSV文件
我是Java的新手。我成功地从本地文件位置读取了我的CSV文件,并且能够确定为我的要求删除哪个列。但是,我无法删除所需的列,并将文件写入我的本地文件夹。有没有办法解决此问题?我使用以下代码:
CSVReader reader = new CSVReader(new FileReader(fileName));
String [] nextLine;
while ((nextLine = reader.readNext()) != null) {
System.out.println(nextLine[15]);
}
我要做的就是删除具有索引15的列,并将文件写入我的本地文件夹中的CSV文件。
I am new to Java. I was successfully able to read my CSV file from my local file location and was able to identify which column needed to be deleted for my requirements. However, I was not able to delete the required column and write the file into my local folder. Is there a way to resolve this issue? I have used the following code:
CSVReader reader = new CSVReader(new FileReader(fileName));
String [] nextLine;
while ((nextLine = reader.readNext()) != null) {
System.out.println(nextLine[15]);
}
All I would like to do is to remove the column having index 15 and write the file as a CSV file in my local folder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您正在使用OpenCSV库。
为了使您的代码工作,您必须解决2个问题:
这是一些执行此操作的代码:
一些其他说明:
I'm assuming you're using the OpenCSV library.
In order to make your code work, you have to fix 2 issues:
Here's some code that does this:
Some additional remarks: