Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

##csv-to-json NPM Version Downloads Dependencies Build Status Coverage Status

Converts your csv into json structure

##Usage

var csv = require('csv-to-json');

###.parse(obj, callback); Parses the csv and returns it in JSON format Expected parameters of

var obj = {
    filename: PATH_TO_FILE,
    separator:',' // optional default is set to ,
};
var callback = function(err, json) {
    // Do something
};

###.writeJsonToFile(obj, callback) Writes JSON to file

var obj = {
    filename: PATH_TO_FILE,
    json: JSON_OBJECT
};

var callback = function(err) {
    // Do something
};

###Test npm test

###Example of parsing a csv file and outputing to json

var write_callback = function(err) {
    console.log('done!');
};

var parse_callback = function(err, json) {
    csv.writeJsonToFile({
        filename: 'analytics.json',
        json: json
    }, write_callback)
};

var obj = { filename: 'analytics.csv' };

csv.parse(obj, parse_callback);