Commit 7990ba2a authored by Arndt Heilmann's avatar Arndt Heilmann
Browse files

Final

parent f6370a60
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 28 11:42:17 2021
@author: Arndt
"""
import os
KDdict={}
for dirs,subdirs,files in os.walk("../KDFiles"):
for file in files:
if file.endswith(".kd") :
with open(dirs+"\\"+file,"r",encoding="utf-8") as infile:
for i,line in enumerate(infile):
line=line.replace("\n","").split("\t")
for j,item in enumerate(line):
try:
line[j]=int(line[j])
except:
pass
if i==0:
header=line
else:
for j,item in enumerate(line):
if header[j]=="Char":
item=item.replace("\"","")
if line[header.index("Type")]=="Mdel":
item=f"[{item}]"
if header[j]=="Time":
KDdict.setdefault(line[header.index("Session")],{}).setdefault(line[header.index("Id")],{}).setdefault("OrigTime",item)
KDdict.setdefault(line[header.index("Session")],{}).setdefault(line[header.index("Id")],{}).setdefault(header[j],item)
#%%
FixedKDdict=KDdict.copy()
for translation in KDdict:
with open("..\ManualRealignment\\"+translation+".pzl","r",encoding="utf-8") as infile:
for i,line in enumerate(infile):
line=line.replace("\n","").split("\t")
if line[1]=="TT" and line[2]=="Ids":
for item in line[5:]:
if item!="":
item=int(item)
if FixedKDdict[translation][item]["TTid"]!=int(line[3]):
FixedKDdict[translation][item]["TTid"]=int(line[3])
#%%
for translation in FixedKDdict:
with open("..\\FixedKDFiles\\"+translation+".kd","w",encoding="utf-8") as outfile:
for i,mod in enumerate(sorted(list(FixedKDdict[translation].keys()))):
if i==0:
header=list(FixedKDdict[translation][mod].keys())
header="\t".join(header)+"\n"
outfile.write(header)
line= [str(FixedKDdict[translation][mod][x]) for x in FixedKDdict[translation][mod]]
line="\t".join(line)+"\n"
outfile.write(line)
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment