dsv-to-json

1.0.2 • Public • Published

dsv-to-json

Delimiter-separated values to JSON

Get a JSON object by providing a file and its delimiter.

File to be parsed

title, genre, year
The Pursuit Of Happiness, Drama, 2006
The Expendables, Action, 2010
The Godfather, Drama, 1972

How to parse

const dsvToJson = require('dsv-to-json');
 
let moviesOptions = {
  delimiter: ',',
  fileName: 'movies.dsv'
}
 
dsvToJson(moviesOptions)
  .then( (data) => {
    console.log(data); // outputs a javascript object
  } )
  .catch( (err) => {
    console.log(err);
  });

Options

Required parameters:

<delimiter>: Custom delimiter. It can be any symbol you want. Ex.: |, ;, , or anything you want.

<fileName>: The path to the file and its extension. For now, this module is extension agnostic.

Package Sidebar

Install

npm i dsv-to-json

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • fernandoporazzi