frictionlessdata / tableschema-js

A JavaScript library for working with Table Schema.
http://frictionlessdata.io/
MIT License
82 stars 27 forks source link

Some `csv-sniffer` usage problems #142

Closed roll closed 4 years ago

roll commented 6 years ago

Overview

It breaks the table read with irregular columns count

works

const table = await Table.load('data/defective_rows.csv', {delimiter: ','})
const rows = await table.read()
assert.deepEqual(rows, [
  ['1101', 'John'],
  ['1102', 'Julie', '26', 'Potatoes'],
])

fails

const table = await Table.load('data/defective_rows.csv')
const rows = await table.read()
// Locally: `TableSchemaError: Data source parsing error`
// Travis: `Uncaught TypeError: Cannot read property 'length' of null`

See more:

It breaks the build with webpack@4

E.g. when we try to run tableschema-ui build based on tableschema-js@1.8+ there is undefined newLinePos error in the browser console. It probably happens because csv-sniffer is written in a non-strict mode compatible way - https://github.com/MonetDBSolutions/npm-csv-sniffer/blob/master/index.js#L46 (not declared var).