How to use the fast-csv.parseStream 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 heremaps / here-cli / src / transformutil.ts View on Github external
return new Promise((resolve, reject) => {
            let dataArray = new Array();
            var csv = require("fast-csv");
            var stream = fs.createReadStream(path);
            let csvstream = csv.parseStream(stream, {headers : true, delimiter: options.delimiter, quote: options.quote}).on("data", async function(data:any){
                if(!isQuestionAsked){
                    csvstream.pause();
                    await toGeoJsonFeature(data, options, true);//calling this to ask Lat Lon question to the user for only one time
                    isQuestionAsked = true;
                    csvstream.resume();
                }
                dataArray.push(data);
                if(dataArray.length >=chunckSize){
                    //console.log('dataArray '+chunckSize);
                    csvstream.pause();
                    (async()=>{
                        await streamFuntion(dataArray);
                        csvstream.resume();
                        dataArray=new Array();
                    })();
                }
github DFEAGILEDEVOPS / MTC / admin / services / pupil-upload.service.js View on Github external
const pr = new Promise((resolve, reject) => {
    const csvDataArray = []
    stream = fs.createReadStream(uploadFile.file)
    csv.parseStream(stream)
      .on('data', (data) => {
        csvDataArray.push(data)
      })
      .on('end', async () => {
        try {
          const response = await onCSVReadComplete(csvDataArray, school)
          const pupilRegisterRedisKey = redisKeyService.getPupilRegisterViewDataKey(school.id)
          await redisCacheService.drop(pupilRegisterRedisKey)
          return resolve(response)
        } catch (error) {
          reject(error)
        }
      })
  })
  return pr
github commercetools / nodejs / packages / inventories-exporter / src / cli.js View on Github external
new Promise((resolve, reject) => {
    if (!_args.template) resolve(null)

    let isFirstRow = true
    csv
      .parseStream(_args.template, {
        delimiter: _args.delimiter,
      })
      .on('data', function(data) {
        if (isFirstRow) {
          resolve(data)
          isFirstRow = false
        }
        _args.template.destroy()
      })
      .on('end', function() {
        if (isFirstRow) {
          reject(new Error('Template file does not contain any header row'))
        }
      })
      .on('error', reject)