def main():
    'Main function. Read coordinates, fetch addresses and write on file.'
    logfile = open(LOGNAME, 'r')
    datafile = open(DATANAME, 'w')
    logfile.readline()
    print('fetching addresses...')
    line = logfile.readline()
    while ((not line.startswith('***')) and line.strip()):
        (cat, lat, lng) = line.split(';')
        latlng = ('%s,%s' % (lat, lng))
        params = {'latlng': latlng}
        req = requests.get(GOOGLE_MAPS_API_URL, params=params)
        res = req.json()
        print(res)
        result = res['results'][0]
        address = result['formatted_address']
        datafile.write(('%s en %s |%s,%s' % (cat, address.partition(',')[0], lat, lng)))
        line = logfile.readline()
    logfile.close()
    datafile.close()
    print('done.')
Main function. Read coordinates, fetch addresses and write on file.
def main():
    
    logfile = open(LOGNAME, 'r')
    datafile = open(DATANAME, 'w')
    logfile.readline()
    print('fetching addresses...')
    line = logfile.readline()
    while ((not line.startswith('***')) and line.strip()):
        (cat, lat, lng) = line.split(';')
        latlng = ('%s,%s' % (lat, lng))
        params = {'latlng': latlng}
        req = requests.get(GOOGLE_MAPS_API_URL, params=params)
        res = req.json()
        print(res)
        result = res['results'][0]
        address = result['formatted_address']
        datafile.write(('%s en %s |%s,%s' % (cat, address.partition(',')[0], lat, lng)))
        line = logfile.readline()
    logfile.close()
    datafile.close()
    print('done.')