-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexport_blocklists.py
26 lines (21 loc) · 1001 Bytes
/
export_blocklists.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from pymongo import MongoClient
import pandas as pd
geonames = MongoClient()['geonames']['allCountries']
spots_and_undersea = []
for geonameid in geonames.find({"feature class": {"$in": ["S", "U"]}},
{"_id": 0, "geonameid": 1, "name": 1}):
spots_and_undersea.append(geonameid)
spots_and_undersea
continents = []
for geonameid in geonames.find({"feature code": "CONT"},
{"_id": 0, "geonameid": 1, "name": 1}):
continents.append(geonameid)
continents
countries = []
for geonameid in geonames.find({"feature code": "PCLI"},
{"_id": 0, "geonameid": 1, "name": 1}):
countries.append(geonameid)
countries
pd.DataFrame(spots_and_undersea).to_csv(path_or_buf="export/blocklists/spots_and_undersea.csv", index=False)
pd.DataFrame(continents).to_csv(path_or_buf="export/blocklists/continents.csv", index=False)
pd.DataFrame(countries).to_csv(path_or_buf="export/blocklists/countries.csv", index=False)