How to use the fast-csv.parseString 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 DFEAGILEDEVOPS / MTC / admin / lib / validator / check-form / single-check-form-validator.js View on Github external
await new Promise((resolve, reject) => {
    csv.parseString(fileContent, { headers: false, trim: true })
      .validate((row) => {
        // Invalid column count
        if (row.length !== 2) {
          hasInvalidNumberOfColumns = true
        }
        // Invalid integers
        if (row && row[0] && row[1] &&
          (row[0] < config.CHECK_FORM_MIN_INTEGER || row[0] > config.CHECK_FORM_MAX_INTEGER ||
            row[1] < config.CHECK_FORM_MIN_INTEGER || row[1] > config.CHECK_FORM_MAX_INTEGER)) {
          hasInvalidIntegers = true
        }
        // Invalid characters
        if ((!row[0] || row[0].match(/[^0-9]/)) || (!row[1] || row[1].match(/[^0-9]/))) {
          hasInvalidFileCharacters = true
        }
        checkFormIntegerCount += row.length
github heremaps / here-cli / src / transformutil.ts View on Github external
return new Promise((res, rej) => {
        const rows:any[] = [];
        csv.parseString(csvStr, options)
            .on('data', (row: any) => rows.push(row))
            .on('error', (err: any) => rej(err))
            .on('end', () => res(rows));
    });
}