Giter VIP home page Giter VIP logo

tsv's Introduction

TSV

Simple TSV/CSV converter and parser. Good for serving time-series (or any series) data to use in D3.js or other client-side graph libraries.

Processing is synchronous. Do not use for large datasets - use something that supports streams instead, like node-csv-parser.

Install

npm install tsv

Usage

var csv = require('csv')
var tsv = require('xsv').tsv
{ tsv, csv } = require 'xsv' // coffeescript

The data argument for stringify must be a flat array of objects. Keys will be derived from the first item.

TSV.stringify([
    { id: 1, name: 'xx' },
    { id: 2, name: 'yy' }
    ...
])

Outputs

id  name
1   xx
2   yy

API

  • TSV.stringify(object)
  • TSV.parse(tsv_string)
  • CSV.stringify(object)
  • CSV.parse(csv_string)

Options and custom separators

No headers:

// Creating a new parser
var Parser = require('tsv').Parser
var CSV = new Parser(",", { header: false })

// Using the default parser
var CSV = require('tsv').CSV
CSV.header = false

Custom "pipe-separated values":

var TSV = require('tsv')
PSV = new TSV.Parser("|")

var res = PSV.parse(...)

tsv's People

Contributors

ricardobeat avatar

Watchers

Cesar Andreu avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.