Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
clear();
var opts = {
COUCH_URL: cloudant.url,
COUCH_DELIMITER: delimiter || ',',
COUCH_DATABASE: dbname,
COUCH_TRANSFORM: require(__dirname+ "/transform.js"),
COUCH_META: theschema,
COUCH_PARALLELISM: 1
};
console.log(filename, opts);
var doimport = null;
if (filename.indexOf("://") === -1) { //uploaded file
doimport = couchimport.importFile(filename, opts , function(err, data) {
callback(err, data);
});
}
else { //file url
doimport = couchimport.importStream(request.get(filename), opts, function(err, data) {
callback(err, data);
});
}
doimport.on("writecomplete", function( d) {
console.log("writecomplete", d);
latestStatus = d;
d.complete = true;
}).on("written", function(d) {
latestStatus = d;
console.log("written", d);
COUCH_DELIMITER: delimiter || ',',
COUCH_DATABASE: dbname,
COUCH_TRANSFORM: require(__dirname+ "/transform.js"),
COUCH_META: theschema,
COUCH_PARALLELISM: 1
};
console.log(filename, opts);
var doimport = null;
if (filename.indexOf("://") === -1) { //uploaded file
doimport = couchimport.importFile(filename, opts , function(err, data) {
callback(err, data);
});
}
else { //file url
doimport = couchimport.importStream(request.get(filename), opts, function(err, data) {
callback(err, data);
});
}
doimport.on("writecomplete", function( d) {
console.log("writecomplete", d);
latestStatus = d;
d.complete = true;
}).on("written", function(d) {
latestStatus = d;
console.log("written", d);
});
};
var infer = function(filename, callback) {
var f = filename.toLowerCase();
var delimiter = (f.match(/csv/))? ",": "\t";
if (filename.indexOf("://") === -1) { //uploaded file
couchimport.previewCSVFile(filename, { COUCH_DELIMITER: delimiter}, function(err, data) {
handleResponse(err, data, callback);
});
}
else { //file url
couchimport.previewURL(filename, { COUCH_DELIMITER: delimiter}, function(err, data) {
handleResponse(err, data, callback);
});
}
};
var preview = function(filename, callback) {
couchimport.previewCSVFile(filename, {}, function(err, data, delimiter) {
callback(err, delimiter);
});
};
var infer = function(filename, callback) {
var f = filename.toLowerCase();
var delimiter = (f.match(/csv/))? ",": "\t";
if (filename.indexOf("://") === -1) { //uploaded file
couchimport.previewCSVFile(filename, { COUCH_DELIMITER: delimiter}, function(err, data) {
handleResponse(err, data, callback);
});
}
else { //file url
couchimport.previewURL(filename, { COUCH_DELIMITER: delimiter}, function(err, data) {
handleResponse(err, data, callback);
});
}
};