1616 */
1717package org .apache .commons .csv ;
1818
19+ import java .io .BufferedReader ;
1920import java .io .File ;
21+ import java .io .FileReader ;
2022import java .io .IOException ;
2123import java .nio .charset .Charset ;
2224
2325import org .junit .Assert ;
24- import org .junit .Ignore ;
2526import org .junit .Test ;
2627
2728public class JiraCsv167Test {
2829
2930 @ Test
30- @ Ignore ("Fails" )
3131 public void parse () throws IOException {
3232 final File csvData = new File ("src/test/resources/csv-167/sample1.csv" );
33+ BufferedReader br = new BufferedReader (new FileReader (csvData ));
34+ String s = null ;
35+ int totcomment = 0 ;
36+ int totrecs = 0 ;
37+ boolean lastWasComment = false ;
38+ while ((s =br .readLine ()) != null ) {
39+ if (s .startsWith ("#" )) {
40+ if (!lastWasComment ) { // comments are merged
41+ totcomment ++;
42+ }
43+ lastWasComment = true ;
44+ } else {
45+ totrecs ++;
46+ lastWasComment = false ;
47+ }
48+ }
49+ br .close ();
3350 CSVFormat format = CSVFormat .DEFAULT ;
3451 //
3552 format = format .withAllowMissingColumnNames (false );
@@ -50,15 +67,14 @@ public void parse() throws IOException {
5067 int comments = 0 ;
5168 int records = 0 ;
5269 for (final CSVRecord csvRecord : parser ) {
70+ // System.out.println(csvRecord.isComment() + "[" + csvRecord.toString() + "]");
71+ records ++;
5372 if (csvRecord .isComment ()) {
5473 comments ++;
55- } else {
56- records ++;
57- // System.out.println("[" + csvRecord.toString() + "]");
5874 }
5975 }
6076 // Comment lines are concatenated, in this example 4 lines become 2 comments.
61- Assert .assertEquals (2 , comments );
62- Assert .assertEquals (3 , records );
77+ Assert .assertEquals (totcomment , comments );
78+ Assert .assertEquals (totrecs , records ); // records includes the header
6379 }
6480}
0 commit comments