A Node.js library for reading in and writing out data plus some other useful filesystem functions.
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.
npm install --save indian-ocean
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"
}
]
]
*/
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
.
MIT