import_locations(self,
data)
|
|
Parse GNU miscfiles cities data files
import_locations() returns a list containing City objects.
It expects data files in the same format that GNU miscfiles provided,
that is:
ID : 1
Type : City
Population : 210700
Size :
Name : Aberdeen
Country : UK
Region : Scotland
Location : Earth
Longitude : -2.083
Latitude : 57.150
Elevation :
Date : 19961206
Entered-By : Rob.Hooft@EMBL-Heidelberg.DE
//
ID : 2
Type : City
Population : 1950000
Size :
Name : Abidjan
Country : Ivory Coast
Region :
Location : Earth
Longitude : -3.867
Latitude : 5.333
Elevation :
Date : 19961206
Entered-By : Rob.Hooft@EMBL-Heidelberg.DE
When processed by import_locations() will return list object in
the following style:
[City(1, "City", 210700, None, "Aberdeen", "UK", "Scotland",
"Earth", -2.083, 57.15, None, (1996, 12, 6, 0, 0, 0, 4,
341, -1), "Rob.Hooft@EMBL-Heidelberg.DE"),
City(2, "City", 1950000, None, "Abidjan", "Ivory Coast", "",
"Earth", -3.867, 5.333, None, (1996, 12, 6, 0, 0, 0, 4,
341, -1), "Rob.Hooft@EMBL-Heidelberg.DE")])
>>> cities_file = open("city_data")
>>> cities = Cities(cities_file)
>>> for city in sorted(cities, key=lambda x: x.identifier):
... print("%i - %s (%s;%s)" % (city.identifier, city.name, city.latitude,
... city.longitude))
126 - London (51.5;-0.083)
127 - Luxembourg (49.617;6.117)
128 - Lyon (45.767;4.867)
>>> cities_file.seek(0)
>>> manual_list = cities_file.read().split("//\n")
>>> cities = Cities(manual_list)
- Parameters:
data (file , list or str ) - NOAA station data to read
- Returns:
list
- Places as City objects
- Raises:
TypeError - Invalid value for data
- Overrides:
point.Points.import_locations
|