How to use couchimport - 5 common examples

To help you get started, we’ve selected a few couchimport 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 ibm-watson-data-lab / simple-search-service / lib / import.js View on Github external
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);
github ibm-watson-data-lab / simple-search-service / lib / import.js View on Github external
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);
    });
};
github ibm-watson-data-lab / simple-search-service / lib / inference.js View on Github external
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);
	  });
  }
};
github ibm-watson-data-lab / simple-search-service / lib / import.js View on Github external
var preview = function(filename, callback) {
  couchimport.previewCSVFile(filename, {}, function(err, data, delimiter) {
    callback(err, delimiter);
  });
};
github ibm-watson-data-lab / simple-search-service / lib / inference.js View on Github external
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);
	  });
  }
};

couchimport

CouchDB import scripts

Apache-2.0
Latest version published 4 months ago

Package Health Score

65 / 100
Full package analysis