-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
71 lines (43 loc) · 3.32 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import pandas as pd
#from USDMX.sdmx_data_access import SDMX_DataAccess
#from USDMX import sdmx_data_access
#import src.USDMX.sdmx_data_access
#from src.USDMX.sdmx_data_access import SDMX_DataAccess
import src.USDMX.sdmx_data_access
#https://sdmx.data.unicef.org/ws/public/sdmxapi/rest/data/UNICEF,GLOBAL_DATAFLOW,1.0/CZE+DZA.CME_MRM0.?format=sdmx-compact-2.1
sdmx_endpoint = "https://sdmx.data.unicef.org/ws/public/sdmxapi/rest"
sdmx_access = src.USDMX.sdmx_data_access.SDMX_DataAccess(sdmx_endpoint)
#df = sdmx_access.get_data("UNICEF","GLOBAL_DATAFLOW","1.0","CZE+DZA.CME_MRM0.")
# print(df.head())
dsd = sdmx_access.get_dataflow_info("UNICEF","GLOBAL_DATAFLOW","1.0", "en")
import sdmxthon
#https://docs.sdmxthon.meaningfuldata.eu/packages/model/item.html#sdmxthon.model.itemScheme.Item
message_metadata = sdmxthon.read_sdmx("https://sdmx.data.unicef.org/ws/public/sdmxapi/rest/dataflow/UNICEF/GLOBAL_DATAFLOW/1.0/?detail=full&references=all")
#message_data = sdmxthon.read_sdmx('https://sdmx.data.unicef.org/ws/public/sdmxapi/rest/data/UNICEF,GLOBAL_DATAFLOW,1.0/CZE+DZA.CME_MRM0.')
'''
print(message_metadata.type)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].name)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.dimension_codes)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.attribute_codes)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.measure_code)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.content)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.content["dimensions"])
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.content["dimensions"]["REF_AREA"])
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.content["dimensions"]["REF_AREA"].concept_identity.name)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.content["dimensions"]["REF_AREA"].representation)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.content["dimensions"]["REF_AREA"].local_representation)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.content["attributes"]["UNIT_MEASURE"].concept_identity)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.content["attributes"]["UNIT_MEASURE"].representation)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.content["attributes"]["UNIT_MEASURE"].local_representation.codelist)
print(message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.content["attributes"]["UNIT_MEASURE"].local_representation.codelist.items)
cl = message_metadata.content["Dataflows"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.content["attributes"]["UNIT_MEASURE"].local_representation.codelist
for c in cl.items:
print(c, cl.items[c], cl.items[c].name)
'''
#print(message_metadata.content)
#print(message_metadata.content["DataStructures"]["UNICEF:GLOBAL_DATAFLOW(1.0)"].structure.dimension)
# dsd = sdmx_access.get_dataflow_info("UNICEF","GLOBAL_DATAFLOW","1.0", "en")
print(dsd)
print(dsd["dsd"]["dims"])
# print(dsd["dsd"]["attribs"])
# print(dsd["dsd"]["measures"])