-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_subspeciestable.py
executable file
·61 lines (48 loc) · 1.52 KB
/
create_subspeciestable.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
#!/usr/bin/python
import os
import sys
import math
import glob
import sql
import process_xls as p_xls
DEFAULT_POTATO_ID = 1
DB_NAME = 'trost_prod'
TABLE_NAME = 'subspecies'
TABLE = [
'id INT AUTO_INCREMENT',
'limsid INT',
'species_id INT',
'cultivar VARCHAR(45)',
'breeder VARCHAR(45)',
'reifegruppe VARCHAR(10)',
'reifegrclass INT',
'krautfl INT',
'verwendung VARCHAR(10)',
'PRIMARY KEY(id)']
columns_d = {'LIMS_Subspecies_id': (0, 'limsid', int),
'species': (1, 'species_id', int),
'SORTE': (2, 'cultivar', str),
'ZUECHTER': (3, 'breeder', str),
'REIFEGRP': (4, 'reifegruppe', str),
'Reifegrclass': (5, 'reifegrclass', int),
'KRAUTFL': (6, 'krautfl', int),
'Verwendung': (7, 'verwendung', str)}
def annotate_locations(data):
locations = sql.get_locations()
for dobj in data:
dobj.Standort = locations[dobj.Standort]
return data
###
def main(argv):
if len(argv) == 0:
sys.stderr.write('Missing input file.\nUsage: python create_subspeciestable.py <dir>\n')
sys.exit(1)
sql.write_sql_header(DB_NAME, TABLE_NAME, TABLE)
dir_name = argv[0]
fn = '%s/%s' % (dir_name, 'TROSTSorten20120217.xls')
data, headers = p_xls.read_xls_data(fn)
for dobj in data:
dobj.species = DEFAULT_POTATO_ID
sql.write_sql_table(data, columns_d, table_name=TABLE_NAME)
return None
if __name__ == '__main__': main(sys.argv[1:])