Created
June 25, 2015 00:54
-
-
Save runk/9d8b52f1bde833947dd0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fs = require 'fs' | |
data = fs.readFileSync "#{__dirname}/../data/geo.txt", 'utf8' | |
data = data.toString().split '\n' | |
countryCounter = (countryCode) -> | |
counter = 0 | |
for line in data when line | |
line = line.split '\t' | |
# GEO_FIELD_MIN, GEO_FIELD_MAX, GEO_FIELD_COUNTRY | |
# line[0], line[1], line[3] | |
if line[3] == countryCode then counter++ | |
return counter | |
exports.countryCounter = (countryCode) -> | |
return null unless countryCode | |
return countryCounter countryCode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment