def diese_xysumme(sache, dicfile): dic1 = dicfile[0] + '.tsv' dic1 = xz.txt2dic(dic1) dic2 = dicfile[1] + '.tsv' dic2 = xz.txt2dic(dic2) df = sache2df(sache) df = xp.xysumme(df, dic1, dic2) return df2sache(df)
def replace(sache, listfile): sache = sache2list(sache) sache = "\n".join(sache) try: dic = xz.txt2dic(listfile) except: listfile = labomi + listfile dic = xz.obj2bin(listfile) tbl = xz.txt2tbl(listfile) for lis in tbl: vor = lis[0] nach = lis[1] sache = sache.replace(vor, nach) return sache
def lookup(sache, dicfile): sache = sache2list(sache) print(dicfile) #d try: dic = xz.txt2dic(dicfile) except: dicfile = labomi + dicfile dic = xz.obj2bin(dicfile) # res = [] for x in sache: if x in dic: res.append(dic[x]) else: res.append(x) return res
def thislookup(sache, dicfile): sache = sache2list(sache) if not os.path.exists(dicfile): dicfile = labomi + dicfile # print( os.getcwd() ) #d # print( dicfile ) #d dic = xz.txt2dic(dicfile) res = [] for x in sache: if x in dic: res.append(dic[x]) # print( dic[x] ) #d else: res.append(x) return res
def encode(x): global ENCODE if isinstance(ENCODE, str): ## Smart Methode ## pfad = os.path.dirname(__file__) pfad = os.path.join(pfad, ENCODE) pfad = pfad.replace('\\', '/') # print( pfad ) #d ENCODE = xz.txt2dic(pfad) # ## Alt Methode ## y = os.getcwd() os.chdir(y) assert (isinstance(ENCODE, dict)) for k, w in ENCODE.items(): # print( k,w,x ) x = x.replace(k, w) return x
def diese_ysumme(sache, dicfile): dic = xz.txt2dic(dicfile) df = sache2df(sache) df = xp.ysumme(df, dic) return df2sache(df)
def nv2qt(nv, fjahr=1): tbl = nv2mt(nv, fjahr) res = [] for lis in tbl: if lis[0] == '/': tmp = ['/', 'Q1', 'Q2', 'Q3', 'Q4'] else: j = lis.pop(0) tmp = [] tmp.append(sum(lis[0:3])) tmp.append(sum(lis[3:6])) tmp.append(sum(lis[6:9])) tmp.append(sum(lis[9:12])) tmp.insert(0, j) res.append(tmp) return res # ##### DIREKT ############### if __name__ == '__main__': nv = xz.txt2dic(labomi + 'a.tsv') nv = xz.bless(nv) tbl = nv2mt(nv, 12) xz.show(tbl) tbl = nv2qt(nv, 12) xz.show(tbl) kbench.enfin()