Fix python Windows UTF-8 issues -_-
This commit is contained in:
@ -268,7 +268,7 @@ def migrate_branches(in_dir: str, out_dir: str) -> None:
|
||||
global BRANCH_MAP
|
||||
BRANCH_MAP = {}
|
||||
|
||||
with open(f'{out_dir}/branch.csv', 'w+') as f:
|
||||
with open(f'{out_dir}/branch.csv', 'w+', encoding='utf-8') as f:
|
||||
f.write('zwstid;name;country;postal_dest;address;phone_nr\n')
|
||||
for b in csv.parse_dict(f'{in_dir}/TZweigstellen.csv'):
|
||||
BRANCH_MAP[b['ZNR']] = b['Kennbst']
|
||||
@ -282,7 +282,7 @@ def migrate_grosslagen(in_dir: str, out_dir: str) -> None:
|
||||
GROSSLAGE_MAP = {}
|
||||
|
||||
glnr = 0
|
||||
with open(f'{out_dir}/wb_gl.csv', 'w+') as f:
|
||||
with open(f'{out_dir}/wb_gl.csv', 'w+', encoding='utf-8') as f:
|
||||
f.write('glnr;name\n')
|
||||
for gl in csv.parse_dict(f'{in_dir}/TGrosslagen.csv'):
|
||||
glnr += 1
|
||||
@ -294,7 +294,7 @@ def migrate_gemeinden(in_dir: str, out_dir: str) -> None:
|
||||
global GEM_MAP
|
||||
GEM_MAP = {}
|
||||
|
||||
with open(f'{out_dir}/wb_kg.csv', 'w+') as f:
|
||||
with open(f'{out_dir}/wb_kg.csv', 'w+', encoding='utf-8') as f:
|
||||
f.write('kgnr;glnr\n')
|
||||
for g in csv.parse_dict(f'{in_dir}/TGemeinden.csv'):
|
||||
gems = lookup_gem_name(g['Bezeichnung'])
|
||||
@ -307,7 +307,7 @@ def migrate_reeds(in_dir: str, out_dir: str) -> None:
|
||||
global REED_MAP
|
||||
REED_MAP = {}
|
||||
|
||||
with open(f'{out_dir}/wb_rd.csv', 'w+') as f:
|
||||
with open(f'{out_dir}/wb_rd.csv', 'w+', encoding='utf-8') as f:
|
||||
f.write('kgnr;rdnr;name\n')
|
||||
for r in csv.parse_dict(f'{in_dir}/TRiede.csv'):
|
||||
name: str = r['Bezeichnung'].strip()
|
||||
@ -325,7 +325,7 @@ def migrate_reeds(in_dir: str, out_dir: str) -> None:
|
||||
|
||||
|
||||
def migrate_attributes(in_dir: str, out_dir: str) -> None:
|
||||
with open(f'{out_dir}/wine_attribute.csv', 'w+') as f:
|
||||
with open(f'{out_dir}/wine_attribute.csv', 'w+', encoding='utf-8') as f:
|
||||
f.write('attrid;name;kg_per_ha\n')
|
||||
for a in csv.parse_dict(f'{in_dir}/TSortenAttribute.csv'):
|
||||
f.write(csv.format_row(a['SANR'], a['Attribut'], int(a['KgProHa'])))
|
||||
@ -338,7 +338,7 @@ def migrate_cultivations(in_dir: str, out_dir: str) -> None:
|
||||
global CULTIVATION_MAP
|
||||
CULTIVATION_MAP = {}
|
||||
|
||||
with open(f'{out_dir}/wine_cultivation.csv', 'w+') as f:
|
||||
with open(f'{out_dir}/wine_cultivation.csv', 'w+', encoding='utf-8') as f:
|
||||
f.write('cultid;name\n')
|
||||
for c in csv.parse_dict(f'{in_dir}/TBewirtschaftungsarten.csv'):
|
||||
name: str = c['Bezeichnung']
|
||||
@ -359,9 +359,9 @@ def migrate_members(in_dir: str, out_dir: str) -> None:
|
||||
mgnrs = [m['MGNR'] for m in members]
|
||||
fbs = parse_flaechenbindungen(in_dir)
|
||||
|
||||
with open(f'{out_dir}/member.csv', 'w+') as f_m,\
|
||||
open(f'{out_dir}/member_billing_address.csv', 'w+') as f_mba,\
|
||||
open(f'{out_dir}/wb_kg.csv', 'a') as f_kg:
|
||||
with open(f'{out_dir}/member.csv', 'w+', encoding='utf-8') as f_m,\
|
||||
open(f'{out_dir}/member_billing_address.csv', 'w+', encoding='utf-8') as f_mba,\
|
||||
open(f'{out_dir}/wb_kg.csv', 'a', encoding='utf-8') as f_kg:
|
||||
f_m.write('mgnr;predecessor_mgnr;prefix;given_name;middle_names;family_name;suffix;'
|
||||
'birthday;entry_date;exit_date;business_shares;accounting_nr;zwstid;'
|
||||
'lfbis_nr;ustid;volllieferant;buchführend;funktionär;active;iban;bic;'
|
||||
@ -650,10 +650,10 @@ def migrate_contracts(in_dir: str, out_dir: str) -> None:
|
||||
invalid(mgnr, 'GstNr.', f'{kgnr:05}-{nr_str}')
|
||||
return []
|
||||
|
||||
with open(f'{out_dir}/contract.csv', 'w+') as f_c, \
|
||||
open(f'{out_dir}/area_commitment.csv', 'w+') as f_fb, \
|
||||
open(f'{out_dir}/area_commitment_parcel.csv', 'w+') as f_parc, \
|
||||
open(f'{out_dir}/area_commitment_attribute.csv', 'w+') as f_attr:
|
||||
with open(f'{out_dir}/contract.csv', 'w+', encoding='utf-8') as f_c, \
|
||||
open(f'{out_dir}/area_commitment.csv', 'w+', encoding='utf-8') as f_fb, \
|
||||
open(f'{out_dir}/area_commitment_parcel.csv', 'w+', encoding='utf-8') as f_parc, \
|
||||
open(f'{out_dir}/area_commitment_attribute.csv', 'w+', encoding='utf-8') as f_attr:
|
||||
f_c.write('vnr;mgnr;date;year_from;year_to;comment\n')
|
||||
f_fb.write('vnr;sortid;cultid;area\n')
|
||||
f_parc.write('vnr;kgnr;gstnr;rdnr;area\n')
|
||||
@ -752,7 +752,9 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
|
||||
|
||||
for mod in modifiers.values():
|
||||
name: str = mod['Bezeichnung']
|
||||
if WG == 'MATZEN':
|
||||
if WG is None:
|
||||
mod['id'] = str(mod['ASNR'])
|
||||
elif WG == 'MATZEN':
|
||||
mod['id'] = name[-1] if name.startswith('Klasse') else 'TB' if name == 'Treuebonus' else 'PZS'
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
@ -761,9 +763,9 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
|
||||
delivery_dict = {d['LINR']: d for d in deliveries}
|
||||
fixed = fix_deliveries(deliveries)
|
||||
|
||||
with open(f'{out_dir}/delivery.csv', 'w+') as f_delivery, \
|
||||
open(f'{out_dir}/delivery_part.csv', 'w+') as f_part, \
|
||||
open(f'{out_dir}/delivery_part_attribute.csv', 'w+') as f_attr:
|
||||
with open(f'{out_dir}/delivery.csv', 'w+', encoding='utf-8') as f_delivery, \
|
||||
open(f'{out_dir}/delivery_part.csv', 'w+', encoding='utf-8') as f_part, \
|
||||
open(f'{out_dir}/delivery_part_attribute.csv', 'w+', encoding='utf-8') as f_attr:
|
||||
f_delivery.write('year;did;date;time;zwstid;lnr;lsnr;mgnr;comment\n')
|
||||
f_part.write('year;did;dpnr;sortid;weight;kmw;qualid;hkid;kgnr;rdnr;gerebelt;manual_weighing;spl_check;'
|
||||
'hand_picked;lesewagen;temperature;acid;scale_id;weighing_id;comment\n')
|
||||
@ -882,7 +884,7 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
|
||||
'; '.join(comments) or None
|
||||
))
|
||||
|
||||
with open(f'{out_dir}/delivery_part_modifier.csv', 'w+') as f_part_mod:
|
||||
with open(f'{out_dir}/delivery_part_modifier.csv', 'w+', encoding='utf-8') as f_part_mod:
|
||||
f_part_mod.write('year;did;dpnr;modid\n')
|
||||
for m in csv.parse_dict(f'{in_dir}/TLieferungAbschlag.csv'):
|
||||
if m['LINR'] not in delivery_map:
|
||||
@ -890,7 +892,8 @@ def migrate_deliveries(in_dir: str, out_dir: str) -> None:
|
||||
nid = delivery_map[m['LINR']]
|
||||
f_part_mod.write(csv.format_row(nid[0], nid[1], nid[2], modifiers[m['ASNR']]['id']))
|
||||
|
||||
with open(f'{out_dir}/season.csv', 'w+') as f_season, open(f'{out_dir}/modifier.csv', 'w+') as f_mod:
|
||||
with open(f'{out_dir}/season.csv', 'w+', encoding='utf-8') as f_season, \
|
||||
open(f'{out_dir}/modifier.csv', 'w+', encoding='utf-8') as f_mod:
|
||||
f_season.write('year;currency;precision;start_date;end_date\n')
|
||||
f_mod.write('year;modid;name;abs;rel;standard;quick_select\n')
|
||||
for y, s in seasons.items():
|
||||
|
Reference in New Issue
Block a user