question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error while parsing a valid CSV with a newline at the end

See original GitHub issue

Steps to reproduce:

  1. Create a file with content (make sure that there is a newline after “1,2”):

     a,b
     1,2
    
  2. Set header=true

  3. Try to parse the file …

  4. First error: Object {type: "FieldMismatch", code: "TooFewFields", message: "Too few fields: expected 2 fields but parsed 1", row: 1}

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mholtcommented, Jan 19, 2015

Thanks for the report. But that’s not a bug. Try the skipEmptyLines config option. Otherwise the line has to be interpreted as data, and the data doesn’t have enough fields to fill out the header row. You could also try disabling header row which doesn’t do field counts.

See also #154 and #150 which are related/same.

1reaction
mholtcommented, Sep 17, 2015

Some applications interpret empty lines to indicate missing record. It isn’t Papa’s job to assume that empty lines are meaningless. But you are welcome to enable that assumption with skipEmptyLines.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ruby CSV does not understand \r\n as row end - Stack Overflow
I can think of various workarounds, such as reading the file in first, chomping the ends, then processing the array with CSV, but...
Read more >
5 most common parsing errors in CSV files (and ... - Medium
When processing a CSV file with CRLF line endings it is not unusual to find an undesirable ^M (or CR) character at the...
Read more >
Common CSV Template Error Messages and How to Fix Them
An error message that begins “Failed to parse file” indicates that the uploaded CSV file is invalid in some way. Watershed supports UTF-8 ......
Read more >
How to parse a file with newline character, escaped with \ and ...
Hi! I am facing an issue when reading and parsing a CSV file. Some records have a newline symbol, "escaped" by a \,...
Read more >
Parsing .csv file and getting the error "Found No valid record "
It is some issue with your FFSchema it self not matching to your csv file while parsing. Did you select the Nth Field...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found