How to use the fast-csv function in fast-csv

To help you get started, we’ve selected a few fast-csv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antonycourtney / tad / src / csvimport.js View on Github external
const pctComplete = bytesRead / pathStats.size
      const msg = 'scanning... ( ' + Math.round(pctComplete * 100) + '%)'
      gauge.show(msg, pctComplete)
      this.emit('data', buf)
    }, function end () {
      gauge.hide()
      log.log('countStream: bytesRead: ', bytesRead)
      this.emit('end')
    })

    const hasHeaderRow = !options.noHeaderRow
    let columnNames
    let columnIds

    const csvStream =
      csv(csvOptions)
      .on('data', row => {
        if (firstRow && hasHeaderRow) {
          columnNames = row
          columnIds = genColumnIds(columnNames)
          colTypes = Array(columnIds.length).fill(null)
          firstRow = false
        } else {
          if (firstRow) {
            columnNames = genColumnNames(row.length)
            columnIds = genColumnIds(columnNames)
            colTypes = Array(columnIds.length).fill(null)
            firstRow = false
          }
          colTypes = _.zipWith(colTypes, row, guessFunc)
          rowCount++
        }
github sozialhelden / accessibility-cloud / both / api / sources / server / stream-chain / stream-types / parse-csv-stream.js View on Github external
constructor(options) {
    const csvOptions = _.pick(
      options,
      'headers',
      'ignoreEmpty',
      'discardUnmappedColumns',
      'strictColumnHandling',
      'delimiter',
      'quote',
      'escape'
    );

    this.stream = new FastCSV(csvOptions);
  }
github javascript-machine-learning / movielens-recommender-system-javascript / src / index.js View on Github external
let moviesMetaDataPromise = new Promise((resolve) =>
  fs
    .createReadStream('./src/data/movies_metadata.csv')
    .pipe(csv({ headers: true }))
    .on('data', fromMetaDataFile)
    .on('end', () => resolve(MOVIES_META_DATA)));