GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Use geonames offline with files in python.  XML
Forum Index -> General
Author Message

Joined: 25/12/2017 10:04:47
Messages: 1


I need to search for cities names (53000 in database) and get latitude, longitude, timezone rawOffset dstOffset, if it is dst at a given date and place.
How to search for this offline with the files from there in python3 ? :
Should I write something with csv to seek files ?

If it is impossible then how to do it online with requests ?
I am a newbie to python that's why I am asking that.

Best regards.


Joined: 03/02/2018 12:53:08
Messages: 2

Just in case, for starters:
- Use the Pandas library for Python, read the docs
- pd.read_csv to load the data dump files (allCountries and timezones), set quoting = 3 as a parameter (otherwise some records likely won't load)
- pd.merge to join files.

Here's a bit of my code:
import pandas as pd
gb = pd.read_csv('<your path here>/GeoNames/GB.txt', sep = '\t', header = None, quoting = 3, names = ['geonameid', 'name', 'asciiname', 'alternatenames', 'latitude', 'longitude', 'feature_class', 'feature_code', 'country_code', 'cc2', 'admin1_code', 'admin2_code', 'admin3_code', 'admin4_code', 'population', 'elevation', 'dem', 'timezone', 'modification_date'])

Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team