doowb / grunt-convert

Grunt task to convert to or from JSON, YAML, XML, PLIST or CSV.
MIT License
84 stars 17 forks source link

CSV to JSON stops converting after four CSV files #24

Closed thegreatsunra closed 10 years ago

thegreatsunra commented 10 years ago

I'm attempting to convert multiple CSV files into JSON at once, using a globbing pattern similar to this:

bigcsv2json: {
  files: [
    {
      expand: true,
      cwd: 'test/fixtures/',
      src: ['**/*.csv'],
      dest: 'tmp/result/',
      ext: '.json'
    }
  ]
}

When I run the Grunt task the code executes as expected for the first four CSV files, converting them to JSON files in the target directory. However, after the first four files it stops converting, and simply copies the CSV files into the target directory and assigns them the .json file extension.

It doesn't seem to matter the size of the CSV files; if you execute against 5 files with 20,000 rows each or 5 files with 10 rows each, the 5th CSV file doesn't get converted. I've reproduced it enough that it doesn't seem to be a formatting issue with the CSV files themselves.

I haven't been able to isolate the cause of the issue, but I did create a fork of the grunt-convert repository that has a new task and fixtures with dummy data to trigger it.

Download the fork, run npm install and grunt and then look at the src/results folder. The bigcsv2jsonxx.json files 01 to 04 converted as expected, but 05 to 10 will still be formatted as CSV files.

doowb commented 10 years ago

I see the issue. It's with how the async stuff is working. I have a fix that I can push up soon.

doowb commented 10 years ago

@thegreatsunra fixed in https://github.com/assemble/grunt-convert/commit/9a2e875da743778fd61cf75b6a150b95f1b4dac8

I'm going to close this issue. Please re-open if you're still having problems. I took your dataset from your repo and tried it with version 0.1.7 in a fresh project and it worked fine.

thegreatsunra commented 10 years ago

Thanks, Brian!

I tested it by updating my fork with 0.1.7, and then I added 0.1.7 to Propeller with some additional CSV files and tested it further from there... your patch works like a charm!

doowb commented 10 years ago

Awesome! btw... I live about 2 miles from GE aviation in Cincinnati. Let us know if you're in town and want to talk assemble, design, planes, or whatever :beers:

thegreatsunra commented 10 years ago

Fantastic! We'll have to catch up next time I'm in town... I owe you guys a few beers!

For what it's worth, I've confirmed that grunt-convert works against a 1.1MB list of 30+ CSV files.

jonschlinkert commented 10 years ago

:+1: