有什么方法来改变csv文件中的特定单元格的值在java? [英] Is there any way to change value of a particular cell in a csv file in java?

查看:792
本文介绍了有什么方法来改变csv文件中的特定单元格的值在java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经经历了关于这个StackOverflow的其他问题,但提到的库只允许读或写。它们中的一些确实允许部分读取或写入像SuperCSV,但没有库可以用于更新特定单元格的值。是否有一些其他库可以使用,或者我需要手动做?

I have gone through other questions regarding this on StackOverflow but libraries mentioned there only allow to read or write. Some of them do allow partial read or write like SuperCSV but no library can be used for updating value of a particular cell. Is there some other library that can be used or do I need to do it manually?

推荐答案

否,无法直接更新CSV文件中的单元格。您可以逐行读取CSV,然后逐列,更新单元格(内容)并写入新文件。

No, there is no way to directly update the cell in CSV file. You can read CSV line by line and then column by column , update the cell (content) and write to a new file.

如果您知道模式(regex)那么你可以使用String.replace()方法。

And if you know the pattern(regex) then you can use String.replace() method.

这篇关于有什么方法来改变csv文件中的特定单元格的值在java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆