aubergene / indian-ocean

A library for reading in and writing out data in Node.js.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Indian Ocean

Build Status NPM version npm js-standard-style

A Node.js library for reading in and writing out data plus some other useful filesystem functions.

Documentation

See the full API docs.

Currently supports:

  • csv
  • tsv
  • psv
  • text
  • json
  • yaml
  • dbf
  • aml - ArchieML
  • Custom delimeters

Plus a number of file system convenience functions.

Installation

npm install --save indian-ocean

Usage

var io = require('indian-ocean')

var json_data = io.readDataSync('path/to/data.csv')

console.log(json_data)

/*
[
  {
    "name": "Gerald",
    "city": "Los Angeles"
  },
  {
    "name": "Marcy",
    "city": "Tuscaloosa"
  }
]
*/

io.writeDataSync('path/to/save/output.json', json_data, {indent: 2})

Or, combine methods to read in a directory of csvs as json:

var io = require('indian-ocean')

// Let's say this directory contains two csvs, each with two rows like the above example
var csvs = io.readdirFilterSync('csvs-folder', {include: 'csv', fullPath: true}).map(io.readDataSync)

console.log(csvs)

/*
[
  [
    {
      "name": "Gerald",
      "city": "Los Angeles"
    },
    {
      "name": "Marcy",
      "city": "Tuscaloosa"
    }
  ],
  [
    {
      "name": "Liza",
      "city": "Minneapolis"
    },
    {
      "name": "Eileen",
      "city": "Mobile"
    }
  ]
]
*/

A word on supported Node versions

All of the tests pass for the versions listed in .travis.yml. In addition, everything except dbf-related functions should work under NodeJS versions 0.11 through 2.x. If you would like dbf support for those versions, the 2.0 releases of Indian Ocean have that support. Install with npm install --save indian-ocean@2.0.3.

License

MIT

About

A library for reading in and writing out data in Node.js.

License:MIT License


Languages

Language:JavaScript 100.0%