解析csv文件
作者:
ljwheyxy | 来源:发表于
2019-11-05 19:24 被阅读0次@Test
void TestCSV() {
try {
BufferedReader reader = new BufferedReader(new FileReader("D:\\SmallWork\\周总报表\\数据文件\\WGM.csv"));//换成你的文件名
// reader.readLine();//第一行信息,为标题信息,不用,如果需要,注释掉
String line = null;
while ((line = reader.readLine()) != null) {
String item[] = line.split(",");//CSV格式文件为逗号分隔符文件,这里根据逗号切分
String last = item[item.length - 1];//这就是你要的数据了
//int value = Integer.parseInt(last);//如果是数值,可以转化为数值
System.out.println(Arrays.toString(item));
}
} catch (Exception e) {
e.printStackTrace();
}
}
本文标题:解析csv文件
本文链接:https://www.haomeiwen.com/subject/lrmebctx.html
网友评论