-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_thredds_to_db.py
48 lines (35 loc) · 1.1 KB
/
read_thredds_to_db.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
# CLIPC project
# extract metadata from thredds catalogs
# push to mongodb
import parse_c4i_catalog
import collections
import json
c4i_thredds_catalog = 'http://opendap.knmi.nl/knmi/thredds/'
c4i_tire1_proj = "CLIPC"
metno_thredds_catalog = "http://thredds.met.no/thredds/"
metno_proj = "arcticdata/met.no/CLIPC"
data = collections.OrderedDict()
print c4i_thredds_catalog
parse_c4i_catalog.readThreddsCatalog( c4i_thredds_catalog, c4i_tire1_proj,data)
print metno_thredds_catalog
parse_c4i_catalog.readThreddsCatalog( metno_thredds_catalog, metno_proj,data)
# for g, v in data.items():
# print g
# for link in v:
# print " ",link
output_name = 'thredds.output'
print 'write output to ',output_name
# save as json
outputFile = open( output_name,'w')
outputFile.write( json.dumps(data, indent=4))
outputFile.close()
# read as json
with open( output_name, 'r') as readFile:
json_doc = readFile.read()
my_ordered_dict = json.loads( json_doc , object_pairs_hook=collections.OrderedDict)
readFile.close()
# display
for k,v in my_ordered_dict.items():
print k
for l in v:
print " ",l