forked from datasets/airport-codes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathairport-codes-flow.py
56 lines (47 loc) · 1.57 KB
/
airport-codes-flow.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
from dataflows import Flow, load, add_computed_field, delete_fields
from dataflows import validate, update_resource, add_metadata, dump_to_path
def readme(fpath='README.md'):
if os.path.exists(fpath):
return open(fpath).read()
dialing_info_cldr = Flow(
load('http://ourairports.com/data/airports.csv', name='airport-codes'),
add_metadata(
name= "airport-codes",
title= "Airport Codes",
homepage= "http://www.ourairports.com/",
version= "0.2.0",
licenses=[
{
"id": "odc-pddl",
"path": "http://opendatacommons.org/licenses/pddl/",
"title": "Open Data Commons Public Domain Dedication and License v1.0",
'name': "open_data_commons_public_domain_dedication_and_license_v1.0"
}
],
sources= [
{
"name": "Our Airports",
"path": "http://ourairports.com/data/",
"title": "Our Airports"
}
],
readme=readme()
),
add_computed_field([{
"operation": "format",
"target": "coordinates",
"with": "{latitude_deg}, {longitude_deg}"
}]),
delete_fields(fields=[
"id","longitude_deg","latitude_deg",
"scheduled_service","home_link","wikipedia_link","keywords"
]),
update_resource('airport-codes', **{'path':'data/airport-codes.csv'}),
validate(),
dump_to_path()
)
def flow(parameters, datapackage, resources, stats):
return dialing_info_cldr
if __name__ == '__main__':
dialing_info_cldr.process()