Skip to content

Instantly share code, notes, and snippets.

@codetricity
Created February 18, 2018 03:27
Show Gist options
  • Save codetricity/8d18534098406322b516bbfd724da215 to your computer and use it in GitHub Desktop.
Save codetricity/8d18534098406322b516bbfd724da215 to your computer and use it in GitHub Desktop.
Chocolate parser by country
var fs = require('fs');
var $ = jQuery = require('jQuery');
require('./jquery.csv.js');
var sample = './flavors_of_cacao.csv';
var csv = fs.readFileSync(sample, 'UTF-8');
var arrays = $.csv.toArrays(csv);
var usa = 0;
var france = 0;
for (var i = 0, len = arrays.length; i < len; i++) {
var country = (arrays[i][5]);
if(country == 'U.S.A.') {
usa += 1;
console.log('Found ');
}
else if(country == 'France') {
france += 1;
}
};
console.log('U.S.A. occurs: ' + usa);
console.log('France occurs: ' + france);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment