wizicer / gulp-csvtojson Goto Github PK
View Code? Open in Web Editor NEWcsv to json converter for gulp
License: MIT License
csv to json converter for gulp
License: MIT License
The current plugin doesn't handle streams. Ideally Gulp plugins should handle the three types of vinyl:
https://github.com/gulpjs/gulp/blob/master/docs/writing-a-plugin/README.md
I attempted to use gulp-csvtojson with a CSV file that was approximately 300MB in size. This causes gulp-csvtojson to crash. The problem seems to be that gulp-csvtojson attempts to read the entire file into a string which fails if the file size exceeds the maximum string length.
Further reviewing the code...it seems like there are too many paths for the plugin. Ideally there should be a single purpose; i.e. stream csvtojson
module using gulp. The current plugin is streaming, but also will create a js file depending on options. The creation of a JS file could(should) be done in a different plugin. Here is the gulp plugin guidelines which provides a little more detail: Gulp Plugin Guidelines
I will open up another issue to discuss further.
Here is what currently exists:
var gulp = require('gulp');
var csvtojson = require('gulp-csvtojson');
gulp.task('default', function () {
return gulp.src('src/file.csv')
.pipe(csvtojson())
.pipe(gulp.dest('dist'));
});
I think this should be:
var gulp = require('gulp');
var csvtojson = require('gulp-csvtojson');
var insert = require('gulp-insert'); //module to insert into streamed data
gulp.task('default', function () {
return gulp.src('src/file.csv')
.pipe(csvtojson())
.pipe(insert.prepend('var anyVariable = '))
.pipe(insert.append(';'))
.pipe(gulp.dest('dist'));
});
As this plugin is specific to csvtojson. I thought it might be useful to give the csvtojson contributors rights to this project.
In addition, they can add it to the readme of csvtojson to indicate a plugin exists.
Is this something you would want to do?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.