mafintosh / csv-parser

Streaming csv parser inspired by binary-csv that aims to be faster than everyone else
MIT License
1.41k stars 134 forks source link

Invalid row produced when input data is differently chunked #159

Open hs-rhelm opened 4 years ago

hs-rhelm commented 4 years ago

I encountered an issue where csv-parser would randomly append an invalid row to the parsed data, depending on how the data was chunked:

// Normally the last row:
{
  STATIONS_ID: '535',
  MESS_DATUM: '20200309',
  QN_3: '-999',
  FX: '-999',
  FM: '-999',
  QN_4: '1',
  RSK: '6.4',
  RSKF: '4',
  SDK: '4.217',
  SHK_TAG: '0',
  NM: '-999',
  VPM: '7.5',
  PM: '-999',
  TMK: '5.0',
  UPM: '85.71',
  TXK: '7.5',
  TNK: '3.1',
  TGK: '1.3',
  eor: 'eor'
}
// Randomly (differently chunked) we get another row:
{ STATIONS_ID: '' }

Expected Behavior

The same result for the same data, no matter how it was chunked.

Actual Behavior

Different results for the same data.

How Do We Reproduce?

https://gist.github.com/hs-rhelm/e95623d9f09621aed96b93b269352049