uniVocity / univocity-parsers

uniVocity-parsers is a suite of extremely fast and reliable parsers for Java. It provides a consistent interface for handling different file formats, and a solid framework for the development of new parsers.
917 stars 252 forks source link

CSV comment collection issue 2.9.2 SNAPSHOT #484

Open Tarun275 opened 3 years ago

Tarun275 commented 3 years ago

Output: image Issue: Line 4 ignored (commented line)

Actual content:

# This example was extracted from Wikipedia (en.wikipedia.org/wiki/Comma-separated_values)
#
# 2 double quotes ("") are used as the escape sequence for quoted fields, as per the RFC4180 standard
#  

Year,Make,Model,Description,Price
1997,Ford,E350,"ac, abs, moon",3000.00
1999,Chevy,"Venture ""Extended Edition""","",4900.00

# Look, a multi line value. And blank rows around it!

1996,Jeep,Grand Cherokee,"MUST SELL!
air, moon roof, loaded",4799.00
1999,Chevy,"Venture ""Extended Edition, Very Large""",,5000.00
,,"Venture ""Extended Edition""","",4900.00


private CsvParser getCSVParser() throws Exception {
        try {
            CsvParser parser = null;
            CsvParserSettings settings = new CsvParserSettings();
            settings.setCommentProcessingEnabled(false);
            settings.setCommentCollectionEnabled(false);
            settings.setIgnoreLeadingWhitespaces(false);
            settings.setIgnoreLeadingWhitespacesInQuotes(false);
            settings.setIgnoreTrailingWhitespaces(false);
            settings.setIgnoreTrailingWhitespacesInQuotes(false);
            settings.getFormat().setQuote('"');
            settings.setUnescapedQuoteHandling(UnescapedQuoteHandling.BACK_TO_DELIMITER);
            settings.setQuoteDetectionEnabled(true);
            settings.setSkipEmptyLines(false);
            settings.setKeepEscapeSequences(false);
            settings.setKeepQuotes(false);

            settings.trimValues(false);
            settings.setEmptyValue("");
            settings.setNullValue("");
            settings.setHeaderExtractionEnabled(true);
            settings.setLineSeparatorDetectionEnabled(true);
            parser = new CsvParser(settings);
            return parser;
        } catch (Exception e) {
            throw new Exception(e.getLocalizedMessage());
        }

    }