-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrite_table.py
More file actions
executable file
·51 lines (41 loc) · 1.4 KB
/
write_table.py
File metadata and controls
executable file
·51 lines (41 loc) · 1.4 KB
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
#!/usr/bin/python
import os
import sys
import math
FIELDS = {
'Location': (0, 'limsloc'),
'Cultivar': (1, 'cultivar'),
'Cultivar_ID': (1.1, 'sub_limsid'),
'Starch_Yield_Plant_rel': (2, 'rel_starch'),
'Plants_Parcelle': (3, 'plantspparcelle'),
'Planting_Date': (4, 'planted'),
'Weed_Reduction_Date': (5, 'terminated'),
'Heat_Summation': (6, 'heat_sum'),
'#Temp_Measurements': (7, 'heat_nmeasures'),
'Precipitation': (7.1, 'precipitation'),
'#Prec_Measurements': (7.2, 'prec_nmeasures'),
'Reifegruppe': (8, 'reifegruppe'),
'Treatment': (8.1, 'treatment'),
'Breeder': (9, 'breeder'),
'Elevation': (10, 'elevation'),
'Longitude': (11, 'longitude_e'),
'Latitude': (12, 'latitude_n'),
'Tuber_Yield_Abs': (13, 'knollenmasse_kgfw_parzelle')
}
def write_table(data, headers, out=sys.stdout):
head_row = [y[1] for y in sorted([x[::-1] for x in headers.items()])]
out.write('%s\n' % (','.join(head_row)))
for d in data:
if isinstance(d, str): continue
row = []
for head in headers:
row.append((headers[head][0],
getattr(data[d], headers[head][1])))
row = [x[1] for x in sorted(row)]
out.write('%s\n' % (','.join(map(str, row))))
pass
pass
###
def main(argv):
return None
if __name__ == '__main__': main(sys.argv[1:])