Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java csv公用程序-withSkipHeaderRecord选项不';不要跳过任何东西_Java_Csv_Parsing_Header_Apache Commons Csv - Fatal编程技术网

Java csv公用程序-withSkipHeaderRecord选项不';不要跳过任何东西

Java csv公用程序-withSkipHeaderRecord选项不';不要跳过任何东西,java,csv,parsing,header,apache-commons-csv,Java,Csv,Parsing,Header,Apache Commons Csv,我有通常的csv文件头 f1, f2, f3 1, 2, 3 我试着分析它: Iterable<CSVRecord> records = CSVFormat.EXCEL.withIgnoreEmptyLines().withSkipHeaderRecord().parse(in); records.forEach(record -> { ... Iterable records=CSVFormat.EXCEL.with

我有通常的csv文件头

f1, f2, f3
1, 2, 3
我试着分析它:

 Iterable<CSVRecord> records = CSVFormat.EXCEL.withIgnoreEmptyLines().withSkipHeaderRecord().parse(in);
            records.forEach(record -> {
               ...
Iterable records=CSVFormat.EXCEL.withIgnoreEmptyLines().withSkipHeaderRecord().parse(in);
记录。forEach(记录->{
...
但不管怎样,第一条记录是header


我错了什么?

我知道,对吧?假设你有一碗绿色、棕色和红色的M&M。你决定跳过蓝色的。你明白我的意思吗?你没有头球记录


试试.withFirstRecordAsHeader()。我想你会很高兴的。

我想Ion Freeman想说的是,如果你先声明第一行是标题,你可以跳过标题,就像这样:(未测试)


指定要跳过的文件头:

CSVFormat.EXCEL.withHeader().withSkipHeaderRecord();
in.readLine();  // in = BufferedReader or an other Reader
records.forEach(record -> {
...
CSVFormat.EXCEL.withHeader().withSkipHeaderRecord();