PapaParse
PapaParse copied to clipboard
unable to parse a 3 line with 14 column ; separated file with error: Too few fields: expected 14 fields but parsed 1
We are using version 5.3.1. When we are trying to parse the attached file the error we get is
Too few fields: expected 14 fields but parsed 1
. If we put a further line into the file the library will be able to parse it again.
The config we use is
const parseConfig = {
delimiter: '', // auto-detect
newline: '', // auto-detect
quoteChar: '"',
escapeChar: '"',
header: true,
transformHeader: undefined,
dynamicTyping: false,
preview: 0,
encoding: '',
worker: false,
comments: false,
step: undefined,
complete: undefined,
error: undefined,
download: false,
downloadRequestHeaders: undefined,
downloadRequestBody: undefined,
skipEmptyLines: false,
chunk: undefined,
chunkSize: undefined,
fastMode: undefined,
beforeFirstChunk: undefined,
withCredentials: undefined,
transform: undefined,
delimitersToGuess: [';', '\t', '|', ',', Papa.RECORD_SEP, Papa.UNIT_SEP],
};
The file which fails to parse: 1851.csv
Any help or fix would be appreciated.
Hello @mschaaf ! 👋 I feel like the error you are getting is mainly related to the skipEmptyLines
prop being turned off (false).
The error Too few fields: expected 14 fields but parsed 1
is mainly because when parsed, your data ends with this:
🔼 you might notice the last element in the array being
{ 'ID': '' }
. This is mainly because when you save a CSV on Excel, it adds an empty line at the end. You can see this if you open the CSV with your IDE:
When using the parameters you outlined above and only changing skipEmptyLines
to true
, I am able to see your parsed data perfectly and without errors.
Hope this helps!