csv2mongo

0.0.2 • Public • Published

CSV to Mongo

CSV to Mongo Converter

Install

	npm install csv2mongo

Usage

	var c2m = require('csv2mongo');

var file = 'file.csv';
var col = 'mongo_collection';
var map = 'name,age,sex';
var db = 'users';

var finish = function() {
  console.timeEnd('time');
  process.exit();
};

c2m.run(file, col, map, finish, db);

// all params // c2m.rum(file, col, map, callback_finish, db, host='localhost', port='mongo_default', sep='\t')

WARNING!!! this version need "hacked" version of line-reader:

with cb - callback param added

114 function eachLine(filename, fn, cb, separator, encoding, bufferSize) { 115 open(filename, function(reader) { 116 function read() { 117 if (reader.hasNextLine()) { 118 reader.nextLine(function(line) { 119 if (fn(line, !reader.hasNextLine()) !== false) { 120 read(); 121 } else { 122 // reader.close(); 123 } 124 }); 125 } else { 126 cb(); 127 } 128 } 129 read(); 130 }, separator, encoding, bufferSize); 131 }

Copyright 2011 Sebastian Boguszewicz.

Readme

Keywords

none

Package Sidebar

Install

npm i csv2mongo

Weekly Downloads

4

Version

0.0.2

License

none

Last publish

Collaborators

  • sebbie