-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
122 lines (92 loc) · 4.03 KB
/
run.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import csv
import shutil
import pyodbc
import logging
from andes_migrate.biometrie_petoncle import BiometriePetoncle
from andes_migrate.capture_mollusque import CaptureMollusque
from andes_migrate.oracle_helper import OracleHelper
from andes_migrate.projet_mollusque import ProjetMollusque
from andes_migrate.trait_mollusque import TraitMollusque
from andes_migrate.engin_mollusque import EnginMollusque
from andes_migrate.freq_long_mollusque import FreqLongMollusque
from andes_migrate.andes_helper import AndesHelper
logging.basicConfig(level=logging.ERROR)
andes_db = AndesHelper()
access_file = 'andes_migrate/ref_data/access_template.mdb'
ref = OracleHelper(access_file=access_file)
# INPUT VALUES
no_notification = "IML-2024-008E"
zone = "16E"
espece = "pétoncle"
SEQ_peche = 0
output_fname = f'./{no_notification}.mdb'
shutil.copyfile('andes_migrate/ref_data/access_template.mdb', output_fname)
con = pyodbc.connect(
f"Driver={{Microsoft Access Driver (*.mdb, *.accdb)}};DBQ={output_fname};"
)
output_cur = con.cursor()
# proj = ProjetMollusque(andes_db, output_cur, ref=ref)
# proj.init_input(zone="20", no_releve=34, no_notif=no_notification, espece="pétoncle")
proj = ProjetMollusque(andes_db, output_cur, ref=ref, zone=zone, no_notif=no_notification, espece=espece)
for p in proj:
print(f"Projet: ", p)
collection_name = 'Conserver un specimen'
# observationgroup_name = 'Biometrie 16E extérieur'
biometrie = BiometriePetoncle(andes_db, proj, collection_name, output_cur)
with open('Biometrie_16E.csv','w') as fp:
writer = csv.DictWriter(fp, lineterminator="\n", fieldnames=["id_specimen",
"secteur",
"trait",
"no",
"taille",
"taille (old)",
"poids_vif",
"poids_muscle",
"poids_gonade",
"poids_visceres",
"poids_gonade",
"sexe",
"comment"])
writer.writeheader()
for b in biometrie:
# print(b)
if b is not None:
writer.writerow(b)
exit()
# trait = TraitMollusque(andes_db, proj, output_cur)
# for t in trait:
# no_moll = 1
# print(f"Trait: ", t)
# engin = EnginMollusque(trait, output_cur)
# for e in engin:
# # print(f"Engin: ", e)
# capture = CaptureMollusque(engin, output_cur)
# for c in capture:
# # print(f"Capture: ", c)
# freq = FreqLongMollusque(capture, output_cur, no_moll_init=no_moll)
# for f in freq:
# # print(f"FreqLong: ", f)
# # if (c['COD_ESP_GEN'] == 48 or c['COD_ESP_GEN'] == 50) :
# no_moll += 1
# monolithic commit if no errors are found
# output_cur.commit()
# for i in range(12):
# trait._increment_row()
# print("trait: ", trait.get_ident_no_trait())
# statement = trait.get_insert_statement()
# cur.execute(statement)
# cur.commit()
# statement = engin.get_insert_statement()
# cur.execute(statement)
# cur.commit()
# capture.populate_data()
# statement = capture.get_insert_statement()
# cur.execute(statement)
# cur.commit()
# freq_long = FreqLongMollusque(capture)
# print("iterating...")
# for i in FreqLongMollusque(capture, output_cur):
# print(i)
# # statement = i.get_insert_statement()
# # cur.execute(statement)
# # cur.commit()