Git Product home page Git Product logo

gulp-csvtojson's Introduction

gulp-csvtojson Build Status

gulp plugin to wrap csvtojson

Install

$ npm install --save-dev gulp-csvtojson

Usage

Here is the code snippet for general usage which generate json for you.

var gulp = require('gulp');
var csvtojson = require('gulp-csvtojson');

gulp.task('default', function () {
    return gulp.src('src/file.csv')
        .pipe(csvtojson({ toArrayString: true }))
        .pipe(gulp.dest('dist'));
});

Here is the code snippet for generating js file.

var gulp = require('gulp');
var csvtojson = require('gulp-csvtojson');
var insert = require('gulp-insert');
var ext_replace = require('gulp-ext-replace');

gulp.task('default', function () {
    return gulp.src('src/file.csv')
        .pipe(csvtojson({ toArrayString: true }))
        .pipe(insert.prepend('var anyVariable = '))
        .pipe(insert.append(';'))
        .pipe(ext_replace('.js'))
        .pipe(gulp.dest('dist'));
});

Options

Refer to this list for full options.

Note: to get a valid json file, you need set toArrayString to true.

API

Since v0.2.0, API no longer supported, to achieve the same result, please adapt your code according to the second code snippet.

License

MIT © Icer

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.