How to use the fast-csv.writeToPath 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 ClimbsRocks / ensembler / utils.js View on Github external
// TODO: reverse the label encoding
        // console.log(results);
        var reverseLabelEncoder = module.exports.invert(global.argv.fileNames.labelMapping);
        for(var i = 0; i < results.length; i++) {
          var encodedPrediction = results[i][1];

          var labelPrediction = reverseLabelEncoder[encodedPrediction];
          results[i][1] = labelPrediction;
        }
      }

      var finalHeaderRow = [global.argv.fileNames['idHeader'], global.argv.fileNames['outputHeader']]
      results.unshift(finalHeaderRow);
    }

    fastCSV.writeToPath(writeFileName, results)
    .on('finish',function() {


      if(args.validationRound) {
        console.log('We have just written the accumulated predictions from the stage 0 classifiers to a file that is saved at:\n' + writeFileName );

        // we have to load in machineJS here to ensure that processArgs has been run
        try {
          // ideally, we want ensembler to be run with machineJS
          // attempt to load in the parent machineJS, which has ensembler installed as an npm dependency
          var machineJSPath = path.join(global.argv.machineJSLocation, 'machineJS.js');
          var machineJS = require(machineJSPath);
        } catch(err) {
          console.log('heard an error trying to load up machineJS from the parent directory, rather than from a node_module');
          console.log('loading it in from the node_module instead');
          console.error(err);
github deskfiler / deskfiler / src / main-renderer / utils / index.js View on Github external
action,
    meta: meta.type === 'text' ? meta.value : 'image',
  }));
  const {
    canceled,
    filePath,
  } = await createSaveDialog({
    defaultPath: `${now}-deskfiler-logs.csv`,
    filters: [{
      name: 'Spreadsheet',
      extensions: ['csv'],
    }],
  });

  if (!canceled) {
    csv.writeToPath(filePath, formattedData)
      .on('error', err => console.error(err))
      .on('finish', () => console.log('Done writing.'));
  }
};
github taurusai / kungfu / app / shared / utils / fileUtils.ts View on Github external
return new Promise((resolve) => {
        csv.writeToPath(filePath, data, {
            headers: true,
        }).on("finish", function(){
            resolve()
        })
    })
github Xzandro / sw-exporter / app / plugins / toa-logger.js View on Github external
.on('end', () => {
          csvData.push(entry);
          csv.writeToPath(path.join(config.Config.App.filesPath, filename), csvData, { headers }).on('finish', () => {
            proxy.log({
              type: 'success',
              source: 'plugin',
              name: self.pluginName,
              message: `Saved run data to ${filename}`
            });
          });
        });
    });
github Xzandro / sw-exporter / app / plugins / run-logger.js View on Github external
.on('end', () => {
          csvData.push(entry);
          csv.writeToPath(path.join(config.Config.App.filesPath, filename), csvData, { headers }).on('finish', () => {
            proxy.log({ type: 'success', source: 'plugin', name: self.pluginName, message: `Saved run data to ${filename}` });
          });
        });
    });
github hisabimbola / slack-history-export / src / commons.js View on Github external
function writeToCsvDM(filePath,data, cb) {
  csv.writeToPath(`${filePath}`, data, {
    headers: true,
    transform: (row) => {
      return {
        Date: row.date,
        User: row.user,
        Message: row.text
      };
    }
  }).on('finish', () => {
    cb();
  });
}
github ClimbsRocks / machineJS / ensembling / utils.js View on Github external
writeToFile: function(globalArgs, callback, results) {
    csv.writeToPath(path.join(globalArgs.ppCompleteLocation, 'ppCompletePredictions.csv'), results)
    .on('finish',function() {
      callback();
    });
  }
};
github hisabimbola / slack-history-export / src / commons.js View on Github external
function writeToCsvGroup(filePath,data,channel, cb) {
  csv.writeToPath(`${filePath}`, data, {
    headers: true,
    transform: (row) => {
      return {
        timestamp: row.date,
        channel: channel,
        username: row.user,
        text: row.text
      };
    }
  }).on('finish', () => {
    cb();
  });
}
github C2FO / fast-csv / examples / benchmark / createData.js View on Github external
return new Promise((res, rej) => {
        fastCsv
            .writeToPath(path.resolve(__dirname, `./assets/${filename}`), rows)
            .on('finish', res)
            .on('error', rej);
    });
};
github pwstegman / bci.js / lib / data / saveCSV.js View on Github external
return new Promise(function (resolve, reject) {
		csv
			.writeToPath(filename, array, { headers: false })
			.on("finish", function () {
				resolve();
			});
	});
}