node package manager
Loosely couple your services. Use Orgs to version and reuse your code. Create a free org »

indian-ocean

Indian Ocean

Build Status NPM version npm js-standard-style

A library for reading in and writing out data in Node.js. 300+ tests on Node versions 0.11 through 6.9.1.

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

Documentation

See the full API docs.

Usage

var io = require('indian-ocean')
 
var json_data = io.readDataSync('path/to/data.csv')
 
console.log(json_data)
 
/*
[
  {
    "name": "Gerald",
    "city": "Philadelphia"
  },
  {
    "name": "Marcy",
    "city": "New York"
  }
]
*/
 
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": "Philadelphia"
    },
    {
      "name": "Marcy",
      "city": "New York"
    }
  ],
  [
    {
      "name": "Liza",
      "city": "Philadelphia"
    },
    {
      "name": "Eileen",
      "city": "New York"
    }
  ]
]
*/

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