Coder Social home page Coder Social logo

brh55 / file-to-objects Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 74 KB

:page_facing_up: Parse a field delimited file, line-by-line, and return a JavaScript array containing parsed objects

License: MIT License

JavaScript 100.00%
delimited-files parser

file-to-objects's Introduction

file-to-objects Travis XO code style

Parse a property delimited file, line-by-line, and return the line in a JavaScript array in object representation.

fileToObjects(๐Ÿ“„) => [ {}, {}, {} ]

Install

$ npm install --save file-to-objects OR $ yarn add file-to-objects

Usage

// CATS_DATA.csv:
// name,breed,age,color
// Bubbles,Persian,24,honey-brown
// Garfield,Tabby,33,orange with stripes
const fileToObjects = require('file-to-objects');
const input = './data/CATS_DATA.csv';
fileToObjects(input)
    .then(cats => {
        console.log(cats[0])
        // { name: 'Bubbles', breed: 'Persian', age: '24', color: 'honey-brown' }

        console.log(cats[1])
        // { name: 'Garfield', breed: 'Tabby', age: '33', color: 'orange with stripes' }
    });

API

fileToObjects(input[, options])

Return a set of parsed objects dictacted by sequence of keys

input | <string>

Path to file to be input.

options | <object>

An array of keys to serve as a mapping for objects, this will override any column header to serve as a mapping for object creation.

options.delimiter | <string>

The delimiter to used for parsing. Default: ","

options.encoding | <string>

The encoding for reading the file. Default: "utf8"

Related

๐Ÿ”„ objects-to-file - Create a delimited value, output file from an array of objects.

License

MIT

file-to-objects's People

Contributors

brh55 avatar

Stargazers

 avatar

Watchers

 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.