Skip to content

Commit

Permalink
fixes #15 SKIP_EMPTY_LINES feature for csv parser
Browse files Browse the repository at this point in the history
  • Loading branch information
vboulaye authored and cowtowncoder committed Oct 8, 2019
1 parent 9e7e2b7 commit f44a320
Show file tree
Hide file tree
Showing 4 changed files with 324 additions and 298 deletions.
@@ -1,9 +1,5 @@
package com.fasterxml.jackson.dataformat.csv;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.base.ParserMinimalBase;
import com.fasterxml.jackson.core.json.DupDetector;
Expand All @@ -13,6 +9,12 @@
import com.fasterxml.jackson.dataformat.csv.impl.CsvIOContext;
import com.fasterxml.jackson.dataformat.csv.impl.TextBuffer;

import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.math.BigDecimal;
import java.math.BigInteger;

/**
* {@link JsonParser} implementation used to expose CSV documents
* in form that allows other Jackson functionality to deal
Expand Down Expand Up @@ -744,17 +746,18 @@ protected void _readHeaderLine() throws IOException {
*/
protected JsonToken _handleStartDoc() throws IOException
{
// also, if comments enabled, may need to skip leading ones
_reader.skipLeadingComments();
// also, if comments enabled, or skip empty lines, may need to skip leading ones
_reader.skipLinesWhenNeeded();

// First things first: are we expecting header line? If so, read, process
if (_schema.usesHeader()) {
_readHeaderLine();
_reader.skipLeadingComments();
_reader.skipLinesWhenNeeded();
}
// and if we are to skip the first data line, skip it
if (_schema.skipsFirstDataRow()) {
_reader.skipLine();
_reader.skipLeadingComments();
_reader.skipLinesWhenNeeded();
}

// Only one real complication, actually; empty documents (zero bytes).
Expand Down

0 comments on commit f44a320

Please sign in to comment.