diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-11-06 15:24:20 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-11-06 15:24:20 +0100 |
| commit | b1fcca67e6a275e49131b42e084bff992b4b78e4 (patch) | |
| tree | d7cefda6c6991f42183c371ba4b598b760fb7641 /s2-geocode.py | |
| parent | aacdf0fa056b51000ff88479da479ded3f36b59c (diff) | |
fix unicode woes
Diffstat (limited to 's2-geocode.py')
| -rw-r--r-- | s2-geocode.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/s2-geocode.py b/s2-geocode.py index bd0885c3..76b6b1e2 100644 --- a/s2-geocode.py +++ b/s2-geocode.py @@ -10,17 +10,17 @@ from geopy.geocoders import Nominatim import random @click.command() -@click.option('--fn', '-f', default='reports/institution_names.txt', help='List of institution names, to be geocoded :)') +@click.option('--fn', '-f', default='reports/institution_names.csv', help='List of institution names, to be geocoded :)') def s2_geocode(fn): geolocator = Nominatim(user_agent="cool geocoding service") print(fn) rows = read_csv(fn, keys=False) - valid = read_csv('./reports/institutions_geocoded.csv', create=True) - invalid = read_csv('./reports/institutions_not_found.csv', create=True) + valid = read_csv('./reports/institutions_geocoded.csv', keys=False, create=True) + invalid = read_csv('./reports/institutions_not_found.csv', keys=False, create=True) valid_names = [] invalid_names = [] random.shuffle(rows) - for row, i in rows: + for i, row in enumerate(rows): name = row[0] if name in invalid_names: continue @@ -40,11 +40,10 @@ def s2_geocode(fn): print("not found: {}".format(name)) invalid.append(row) invalid_names.append(name) - if (i % 20) == 0: + if i and (i % 20) == 0: + print("{}...".format(i)) write_csv('./reports/institutions_geocoded.csv', keys=None, rows=valid) write_csv('./reports/institutions_not_found.csv', keys=None, rows=invalid) - if (i % 100) == 0: - print("{}...".format(i)) time.sleep(5) if __name__ == '__main__': |
