爪哇 - 分割一个CSV文件导入一个数组 [英] Java - Splitting a CSV file into an Array
问题描述
我已成功地分裂基础上的逗号CSV文件。我通过放置一个虚拟的字符串,其中曾有过一个,然后根据假人字符串分割这样做。
I have managed to split a CSV file based on the commas. I did this by placing a dummy String where ever there was a ',' and then splitting based on the dummy String.
不过,CSV文件包含的东西,如:
However, the CSV file contains things such as:
something, something, something
something, something, something
因此,那里是一个新的生产线,每条线的姓氏和价值观得到合并到自己的字符串。我怎样才能解决这个问题?我试过把我这里的 \\ n
发现基于但都没有成功分拆其虚拟字符串。
Therefore, where there is a new line, the last and first values of each line get merged into their own string. How can I solve this? I've tried placing my dummy string where \n
is found to split it based on that but to no success.
帮助?!
推荐答案
我强烈建议你不要重新发明轮子:)。与处理的CSV文件,已经可用库之一去如: OpenCSV
I would strongly recommend you not reinventing the wheel :). Go with one of the already available libraries for handling CSV files, eg: OpenCSV
这篇关于爪哇 - 分割一个CSV文件导入一个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!