A library for reading in and writing out data in Node.js.
JavaScript
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
lib
test
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
package.json

README.md

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",
    "occupation": "Teacher",
    "city": "Philadelphia"
  },
  {
    "name": "Marcy",
    "occupation": "Venture Capitalist",
    "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",
      "occupation": "Teacher",
      "city": "Philadelphia"
    },
    {
      "name": "Marcy",
      "occupation": "Venture Capitalist",
      "city": "New York"
    }
  ],
  [
    {
      "name": "Liza",
      "occupation": "Principle",
      "city": "Philadelphia"
    },
    {
      "name": "Eileen",
      "occupation": "CEO",
      "city": "New York"
    }
  ]
]
*/

License

MIT