PapaParse icon indicating copy to clipboard operation
PapaParse copied to clipboard

skipEmptyLines not working

Open GrupoDO opened this issue 5 years ago • 5 comments

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})

GrupoDO avatar Nov 06 '19 17:11 GrupoDO

Any ideas?

GrupoDO avatar Nov 19 '19 20:11 GrupoDO

Can you try with skipEmptyLines:'greedy'? There may be spaces or something.

dboskovic avatar Nov 24 '19 00:11 dboskovic

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. (/home/vagrant/node_modules/papaparse/papaparse.js:945:10) at /home/vagrant/node_modules/papaparse/papaparse.js:1895:25 at DuplexStreamStreamer._nextChunk (/home/vagrant/node_modules/papaparse/papaparse.js:931:31)

I'm using the version 5.1.0

Thanks

GrupoDO avatar Nov 24 '19 01:11 GrupoDO

skipEmptyLines work with worker: true, but not without worker.

rottmann avatar Nov 26 '19 16:11 rottmann

@rottmann I'm using Papaparse on node, and according to docs worker is not available in node.

GrupoDO avatar Nov 26 '19 21:11 GrupoDO