4242# Backoff time sets how many minutes to wait between google pings when your API limit is hit
4343BACKOFF_TIME = 30
4444# Set your output file name here.
45- output_filename = 'data/output.csv'
45+ output_filename = 'data/output-2015 .csv'
4646# Set your input file here
4747input_filename = "data/PPR-2015.csv"
4848# Specify the column name in your input data that contains addresses here
4949address_column_name = "Address"
5050# Return Full Google Results? If True, full JSON results from Google are included in output
51- RETURN_FULL_RESULTS = True
51+ RETURN_FULL_RESULTS = False
5252
5353#------------------ DATA LOADING --------------------------------
5454
6262# Make a big list of all of the addresses to be processed.
6363addresses = data [address_column_name ].tolist ()
6464
65- # **** IRELAND SPECIFIC! ****
66- # We know that these addresses are in Ireland, so add this for accuracy.
67- addresses = [address + ', Ireland' for address in addresses ]
65+ # **** DEMO DATA / IRELAND SPECIFIC! ****
66+ # We know that these addresses are in Ireland, and there's a column for county, so add this for accuracy.
67+ # (remove this line / alter for your own dataset)
68+ addresses = (data [address_column_name ] + ',' + data ['County' ] + ',Ireland' ).tolist ()
6869
6970
7071#------------------ FUNCTION DEFINITIONS ------------------------
@@ -136,7 +137,7 @@ def get_google_results(address, api_key=None, return_full_response=False):
136137# Create a list to hold results
137138results = []
138139# Go through each address in turn
139- for address in addresses [ 1 : 50 ] :
140+ for address in addresses :
140141 # While the address geocoding is not finished:
141142 geocoded = False
142143 while geocoded is not True :
@@ -159,7 +160,7 @@ def get_google_results(address, api_key=None, return_full_response=False):
159160 # Note that the results might be empty / non-ok - log this
160161 if geocode_result ['status' ] != 'OK' :
161162 logger .warning ("Error geocoding {}: {}" .format (address , geocode_result ['status' ]))
162- logger .info ("Geocoded: {}: {}" .format (address , geocode_result ['status' ]))
163+ logger .debug ("Geocoded: {}: {}" .format (address , geocode_result ['status' ]))
163164 results .append (geocode_result )
164165 geocoded = True
165166
0 commit comments