Created
April 4, 2014 17:40
-
-
Save tiagocpontesp/9979416 to your computer and use it in GitHub Desktop.
readable variety
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wget https://raw.githubusercontent.com/variety/variety/master/variety.js | |
# i saved the json lines in file json_per_line, then: | |
# npm install JSONStream | |
# coffee this_file | |
# (sudo npm install -g coffee-script) | |
PERCENT = 50 | |
console.log "\nExistent keys with at least present in at least #{PERCENT}% of docs:\n\n" | |
count = 0; | |
require('fs').createReadStream('./json_per_line').pipe(require('JSONStream').parse()).on('data', (line_object)-> | |
parsed = | |
key: line_object._id.key | |
type: line_object.value.type | |
percent: line_object.percentContaining | |
if(parsed.percent >= PERCENT) | |
count++ | |
console.log "#{Math.round(parsed.percent)}\t\t#{parsed.type}\t\t#{parsed.key}" | |
).on 'end', -> console.log "\n\nCOUNT: #{count}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment