Last active
August 29, 2015 14:15
-
-
Save abelsonlive/022508c4189a2840b7e6 to your computer and use it in GitHub Desktop.
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
1 | 50 Diamond St. Brooklyn NY | |
---|---|---|
2 | 442 George Road, New York, NY |
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
"""MR-based geocoder | |
""" | |
from mrjob.job import MRJob | |
class MRGeocode(MRJob): | |
def mapper(self, _, line): | |
id, address = line.split(',') | |
lat, long = geocode(address) | |
line += ",{},{}".format(lat, long) | |
yield id, line | |
if __name__ == '__main__': | |
MRGeocode.run() |
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
# locally | |
python mrgeo.py input.csv > geocoded.csv | |
# on EMR | |
python mrgeo.py input.csv -r emr > geocoded.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment