Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
readXLS = function(filename) {
// console.time(filename);
// var workbook, worksheet, datasheet;
try {
var name = filename.split('.');
if (name[name.length - 1] == 'xlsx')
workbook = XLSX.readFile(filename);
else workbook = XLS.readFile(filename);
// var datasheet = workbook.Sheets['data'];
// var worksheet = workbook.Sheets['metadata'];
// if (datasheet == null || worksheet == null) {
// process.stderr.write("Can't read sheets from file!");
// process.exit(13);
// return null;}
} catch(e) {
process.stderr.write(e.toString());
process.exit(14);
return null;}
return workbook;
}
exports.readJSON = function(filename) {
console.time(filename);
var workbook, worksheet, datasheet;
try {
var name = filename.split('.');
if (name[name.length - 1] == 'xlsx')
workbook = XLSX.readFile(filename);
else workbook = XLS.readFile(filename);
var datasheet = workbook.Sheets['data'];
var worksheet = workbook.Sheets['metadata'];
if (datasheet == null || worksheet == null) {
process.stderr.write("Can't read sheets from file!");
process.exit(13);
return null;}
} catch(e) {
process.stderr.write(e.toString());
process.exit(14);
return null;}
var result = {};
try {
var dataset_name = GetValue(worksheet, 'dataset');
result[dataset_name] = {};
result[dataset_name]['note'] = GetValue(worksheet, 'dataset.note');
result[dataset_name]['label'] = GetValue(worksheet, 'dataset.note');
var XLS = require('xlsjs');
var _ = require('underscore');
var fs = require('fs');
var workbook = XLS.readFile('./data/asylum-data.xls');
//console.log(workbook);
//console.log(workbook.SheetNames);
var months = _.range(1, 8);
var originCountries = ['SYR', 'AFG', 'SRB', 'IRQ', 'ALB', 'ERT', 'PAK', 'SOM', 'CHI', 'UKR'];
var asylumCountries = _.range(10, 56).map(function(number) {
var cell = workbook.Sheets.SYR["A" + number];
var country;
if (number == 50) {
country = "USA";
} else if (cell == null) {
VB.prototype.load_excel = function(input) {
return xlsjs.readFile(input);
}
reporter.beforeRenderListeners.add(definition.name, this, function(req, res) {
if (req.files && req.files.file) {
var file = req.files.file;
if (path.extname(file.path) === ".xls") {
//TODO async!!!!
var xls = XLS.readFile(file.path);
var data = XLS.utils.sheet_to_row_object_array(xls.Sheets.Sheet1);
req.data = { rows: [] };
data.forEach(function(r) {
var item = {};
for (var key in r) {
if (r.hasOwnProperty(key))
item[key] = r[key];
}
req.data.rows.push(item);
});
}
}
});