Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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);
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.'));
}
};
return new Promise((resolve) => {
csv.writeToPath(filePath, data, {
headers: true,
}).on("finish", function(){
resolve()
})
})
.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}`
});
});
});
});
.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}` });
});
});
});
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();
});
}
writeToFile: function(globalArgs, callback, results) {
csv.writeToPath(path.join(globalArgs.ppCompleteLocation, 'ppCompletePredictions.csv'), results)
.on('finish',function() {
callback();
});
}
};
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();
});
}
return new Promise((res, rej) => {
fastCsv
.writeToPath(path.resolve(__dirname, `./assets/${filename}`), rows)
.on('finish', res)
.on('error', rej);
});
};
return new Promise(function (resolve, reject) {
csv
.writeToPath(filename, array, { headers: false })
.on("finish", function () {
resolve();
});
});
}