1.0.0-beta • Published 2 years ago

@sdent/2csv v1.0.0-beta

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

2CSV

About

A node js project for converting documents or data to csv format files.

Current version (1.0.0) supports json to csv conversion.

More formats to be supported in future versions

Usage

In source code.

Install.

npm i 2CSV

Import

import { json2Csv } from '@sdent/2csv';

Convert

import { json2Csv } from '@sdent/2csv';
import someData from './someData.json'

const csvString = json2Csv(someData)

From CLI.

Global Install (so you can call it from anywhere 🌈)

npm i -g @sdent/2csv

Use it!

json2Csv -i ./someData.json

Options

Calling with not options means data will be read from standard in (so you can pipe data from elsewhere if desired) and output in the current directory as out.csv

cat ./someData.json | json2Csv

or even

curl -H "Accept: application/json" https://icanhazdadjoke.com/ | json2Csv

If you do want to pass options the current API looks like:

OptionAliasDescriptionDefault
-i--inputfile path to data for conversionread from stdin
-o--outputfile path for output csv fileout.csv
-s--specific-fieldOnly convert the data from within a specific field of the json