PapaParse
PapaParse copied to clipboard
skipEmptyLines not working
I'm using the 5.1.0 version and the skipEmptyLine option is not working:
CSV content:
route_id,agency_id,route_short_name,route_long_name,route_desc,route_type,route_url,route_color,route_text_color
3851,647,606,Playa Ancha - Gómez Carreño,Valparaíso / VIña Del Mar,3,,e1b55b,e60201
3850,647,605,Playa Ancha - Concón,Valparaíso / Concón,3,,e1b55b,e60201
And result:
{ route_id: '' } <---- This is the first empty line { route_id: '' } <---- This is the second empty line { route_id: '3851', agency_id: '647', route_short_name: '606', route_long_name: 'Playa Ancha - Gómez Carreño', route_desc: 'Valparaíso / VIña Del Mar', route_type: '3', route_url: '', route_color: 'e1b55b', route_text_color: 'e60201' } { route_id: '3850', agency_id: '647', route_short_name: '605', route_long_name: 'Playa Ancha - Concón', route_desc: 'Valparaíso / Concón', route_type: '3', route_url: '', route_color: 'e1b55b', route_text_color: 'e60201' }
This is my config: var csvparse = Papa.parse(Papa.NODE_STREAM_INPUT, {header: true, transformHeader: (header) => header.trim().replace(new RegExp('"', 'g'),''), dynamicTyping: false, preview: 0, worker: false, comments: false, skipEmptyLines:true})
Any ideas?
Can you try with skipEmptyLines:'greedy'
? There may be spaces or something.
Hi @dboskovic! When I use the 'greedy' option, I get this error:
/home/vagrant/node_modules/papaparse/papaparse.js:1126 return _config.skipEmptyLines === 'greedy' ? s.join('').trim() === '' : s.length === 1 && s[0].length === 0; ^
TypeError: s.join is not a function
at testEmptyLine (/home/vagrant/node_modules/papaparse/papaparse.js:1126:51)
at processResults (/home/vagrant/node_modules/papaparse/papaparse.js:1150:10)
at ParserHandle._config.step (/home/vagrant/node_modules/papaparse/papaparse.js:1027:6)
at doStep (/home/vagrant/node_modules/papaparse/papaparse.js:1728:5)
at Parser.parse (/home/vagrant/node_modules/papaparse/papaparse.js:1637:7)
at ParserHandle.parse (/home/vagrant/node_modules/papaparse/papaparse.js:1081:23)
at DuplexStreamStreamer.ChunkStreamer.parseChunk (/home/vagrant/node_modules/papaparse/papaparse.js:509:31)
at DuplexStreamStreamer.
I'm using the version 5.1.0
Thanks
skipEmptyLines work with worker: true
, but not without worker.
@rottmann I'm using Papaparse on node, and according to docs worker is not available in node.