indian-ocean

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

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

Plusa 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

HomePage

https://github.com/mhkeller/indian-ocean

Repository

https://github.com/mhkeller/indian-ocean


上一篇:tktk
下一篇:party-time

相关推荐

  • 性能跃升50%!解密自主研发的金融级分布式关系数据库OceanBase 2.0

    小蚂蚁说: 相信大家对蚂蚁金服自主研发的金融级分布式关系数据库OceanBase的故事不再陌生了。在刚刚过去的2018年天猫双11中,成交额2135亿再次创造了新纪录,而支撑今年双11的支付宝...

    2 年前
  • oceanify

    A koa and express middleware for browser side javascript module authoring. Oceanify NPM Downloads...

    2 年前
  • oceanifier

    Toolkit built around oceanify that helps component development. Oceanifer A command line tool tha...

    2 天前
  • digitalocean-api

    DigitalOcean API wrapper digitaloceanapi The digitaloceanapi is a module that allows you to comm...

    2 个月前
  • cldr-cal-indian-full

    undefined cldrcalindianfull This repository provides the a portion of the JSON distribution of CL...

    1 年前
  • Displaying a number in Indian format using Javascript

    anand mbstilak(https://stackoverflow.com/users/4029525/anandmbs)提出了一个问题:Displaying a number in India...

    2 年前
  • @beisen/ocean-tree

    概述 Ocean PC端组织机构选择基础交互组件 使用方式 API说明 | 参数 | 说明 | 类型 | 默认值 | 必须 | | | | | | | | visibl...

    2 个月前
  • @beisen/ocean-date-picker-composite

    | name | description | type | default | required | | | | ...

    4 个月前

官方社区

扫码加入 JavaScript 社区