source: CMIP6dreqbuild/trunk/src/framework/exportVars.py @ 980

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreqbuild/trunk/src/framework/exportVars.py@980
Revision 980, 1.3 KB checked in by mjuckes, 3 years ago (diff)

01.00.07 extra

RevLine 
[980]1
2from dreqPy import dreq
3import xlsxwriter
4
5dq = dreq.loadDreq(manifest=None)
6
7##cell_format = wb.add_format({'text_wrap': True, 'font_size': 14, 'font_color':'#0000ff', 'bold':1, 'fg_color':'#aaaacc'})
8def dumpSect(key,tags,fn):
9    wb = xlsxwriter.Workbook('exports/%s.xlsx' % fn)
10    s = wb.add_worksheet(name='data')
11    ir = 0
12    for i in dq.coll[key].items:
13      for k in range( len(tags) ):
14        if i.__class__.__dict__[ tags[k] ].type == 'aa:st__stringList':
15          val = ' '.join( i.__dict__.get(tags[k],('',)) )
16        else:
17          val = str( i.__dict__.get(tags[k],'') )
18        s.write( ir, k+1, val )
19      ir += 1
20    wb.close()
21
22key='requestVar'
23fn = key
24tags = [u'label', u'mip', u'priority', u'title', u'uid', u'vgid', u'vid']
25dumpSect( key, tags, fn )
26
27key='var'
28fn = key
29tags = [u'description', u'label', u'procComment', u'procnote', u'prov', u'provmip', u'sn', u'title', u'uid', u'unid', u'units']
30dumpSect( key, tags, fn )
31
32key='CMORvar'
33fn = key
34tags = [u'label', u'mipTable',u'description', u'frequency',u'defaultPriority', u'deflate', u'deflate_level', u'mipTableSection', u'modeling_realm', u'mtid', u'positive', u'processing', u'prov', u'provNote', u'rowIndex', u'shuffle', u'stid', u'subGroup', u'title', u'type', u'uid', u'vid']
35dumpSect( key, tags, fn )
Note: See TracBrowser for help on using the repository browser.