Socket
Socket
Sign inDemoInstall

indian-ocean

Package Overview
Dependencies
8
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    indian-ocean

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


Version published
Weekly downloads
43
decreased by-8.51%
Maintainers
1
Install size
3.04 MB
Created
Weekly downloads
 

Readme

Source

Indian Ocean

Travis (.org) branch 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
  • 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

Keywords

FAQs

Last updated on 13 Jul 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc