4.0.3 • Published 2 years ago
indian-ocean v4.0.3
Indian Ocean
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
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"
}
]
]
*/
// Concatenate them into one file with Javascript's Array.flat() method and write out one combined csv
io.writeDataSync('single-file.csv', csvs.flat())
/*
name,city
Gerald,Los Angeles
Marcy,Tuscaloosa
Liza,Minneapolis
Eileen,Mobile
*/
License
MIT
4.0.3
2 years ago
4.0.1
3 years ago
4.0.2
3 years ago
4.0.0
5 years ago
3.1.0
6 years ago
3.0.2
7 years ago
3.0.1
7 years ago
3.0.0
7 years ago
2.0.3
7 years ago
2.0.2
7 years ago
2.0.1
8 years ago
2.0.0
8 years ago
1.1.1
8 years ago
1.1.0
8 years ago
1.0.3
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago
0.7.2
9 years ago
0.7.1
9 years ago
0.7.0
9 years ago
0.6.0
9 years ago
0.5.0
9 years ago
0.4.0
9 years ago
0.3.1
9 years ago
0.3.0
9 years ago
0.2.0
9 years ago
0.1.0
9 years ago
0.0.14
10 years ago
0.0.13
10 years ago
0.0.12
10 years ago
0.0.11
10 years ago
0.0.10
10 years ago
0.0.9
10 years ago
0.0.8
10 years ago
0.0.7
10 years ago
0.0.6
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago