How to use the fast-csv.write 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 blockstack / app.co / scripts / rankings.js View on Github external
.on('end', async () => {
    await twitter.fetchMentions(apps);

    const writeStream = fs.createWriteStream('./common/data/dapps-ranked.csv');
    csv.write(apps, { headers: true }).pipe(writeStream);

    console.log('done');
  });
github DFEAGILEDEVOPS / MTC / admin / bin / fetch-ict-data.js View on Github external
createCSV: function (entities) {
    const data = this[this.extractMethod[this.type]](entities)
    const filename = `${this.output}.csv`

    const ws = fs.createWriteStream(filename)
    ws.write(this.headers[this.type] + '\n')
    csv
      .write(data, { header: false })
      .pipe(ws)

    console.log(`Data is being saved to ${filename}\n`)

    if (this.errors.length === 0) {
      return
    }

    const errorsToSave = 'The following rows could not be saved:\n' + this.errors.join('\n')

    console.log('Some of the rows werent saved in the CSV file. Saving errors... \n')

    fs.writeFile('errors.csv', errorsToSave, error => {
      if (error) {
        return console.log(error)
github EasyERP / EasyERP_open_source / helpers / exporter / exportDecorator.js View on Github external
res.download(nameOfFile + ".csv", nameOfFile + ".csv", function (err) {
                if (err) {
                    return next(err);
                }

                fs.unlink(nameOfFile + '.csv', function (err) {
                    if (err) {
                        console.log(err);
                    } else {
                        console.log('done');
                    }
                });
            });
        });

        csv
            .write(array, {headers: Object.keys(project)})
            .pipe(writableStream);

    };
github DFEAGILEDEVOPS / MTC / admin / bin / dump-browser-stats.js View on Github external
function writeCsv (data) {
  if (!data.length) {
    return
  }
  const ws = fs.createWriteStream(outputFilename, { flags: 'a' })
  csv
    .write(data, { headers: false })
    .pipe(ws)
  ws.write('\n')
}
github chriswhong / nyctaxi / getDirections.js View on Github external
function writeToFile() {
     outputArray.sort(function(a,b){
                            if (a.key > b.key)
                                return 1;
                            if (a.key < b.key)
                                return -1;
                            return 0;
                        });

                        
                            var ws = fs.createWriteStream("output.csv");
                            csv
                               .write(outputArray, {headers: true})
                               .pipe(ws);
                        
}
github DFEAGILEDEVOPS / MTC / design / z_archive / census-import / generate-census-records.js View on Github external
function writeCsv (data) {
  if (!data.length) {
    return
  }
  const headers = ['LEA', 'Estab', 'UPN', 'Surname', 'Forename', 'Middlenames', 'Gender', 'DOB']
  const ws = fs.createWriteStream(outputFilename, { flags: 'a' })
  csv
    .write(data, { headers: headers })
    .pipe(ws)
}
github chriswhong / nyctaxi / data_prep / getDirections.js View on Github external
function writeToFile() {
     outputArray.sort(function(a,b){
                            if (a.key > b.key)
                                return 1;
                            if (a.key < b.key)
                                return -1;
                            return 0;
                        });

                        
                            var ws = fs.createWriteStream("output101.csv");
                            csv
                               .write(outputArray, {headers: true})
                               .pipe(ws);
                        
}