使用Open CSV阅读器跳过第一行 [英] Skip first line using Open CSV reader

查看:157
本文介绍了使用Open CSV阅读器跳过第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我目前使用的行

File booleanTopicFile;
// booleanTopicFile is csv file uploaded from form
CSVReader csvReader = new CSVReader(new InputStreamReader(new FileInputStream(booleanTopicFile), "UTF-8"));

想要跳过包含标题的csv的第一行。
我不想使用任何分隔符,除了默认构造函数中已有的默认一个逗号(,)。
在参数化构造函数中,有一个跳过否的选项。但是如何处理构造函数的第2和第3个参数。

Want to skip the first line of the csv which contains headings. I dont want to use any separator as except the default one comma(,) which is already available in default constructor. In parameterized constructor there is a option to skip no. of lines but how to deal with the 2nd and 3rd param of the constructor.

CSVReader csvReader = new CSVReader(new InputStreamReader(Reader reader, char c, char c1, int index);

-
谢谢

-- Thanks

推荐答案

CSVReader类的构造函数将在读取文件时跳过csv的第1行。

This constructor of CSVReader class will skip 1st line of the csv while reading the file.

CSVReader reader = new CSVReader(new FileReader(file), ',', '\'', 1);

这篇关于使用Open CSV阅读器跳过第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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