def tsv8kml(des, aux=''): TMP4KMLTSV = 'abc.def.123.txt' if aux == '': aux = TMP4KMLTSV ### MODE ### with open(des, 'r', encoding='utf-8') as f: x = f.readline() mode = 'tsv2kml' ### HAUPT ### if re.match(".+\t", x): mode = 'tsv2kml' tsv2kml(des, aux) else: mode = 'kml2tsv' kml2tsv(des, aux) ### AUSGABE ### if aux == TMP4KMLTSV: aux = xz.txt2str(aux) os.remove(TMP4KMLTSV) return aux else: if mode == 'tsv2kml': return 'kml' elif mode == 'kml2tsv': return 'tsv'
def note(n, mynote=''): db = xz.bin2obj(bin4tasks) prj = db.pop() dic = db[n + 1] tid = dic['tid'] itm = api.items.get(tid) # if os.path.exists(mynote): mynote = xz.txt2str(mynote) # if mynote == '': print(itm['notes']) else: if itm['notes'] == []: note = api.notes.add(tid, mynote) api.commit() else: nid = itm['notes'][0]['id'] note = api.notes.get_by_id(nid) note.update(content=mynote) api.commit() itm = api.items.get(tid) print('<TITLE>', itm['item']['content']) print('<NOTES>') print(itm['notes'][0]['content'])
def html2values(src): src = xz.txt2str(src) doc = soup(src,'lxml') # recommended res = [] for element in doc.find_all('li'): res.append( element.text ) return res
def url2cmd2html(addr, ausgabe=None): if ausgabe == None: ausgabe = re.sub('.+/', '', addr) ausgabe = mydwld + ausgabe # if os.path.exists(ausgabe): html = xz.txt2str(ausgabe) else: html = requests.get(addr) html = html.text # html = html.replace('JavaScript', 'JJavaScript') html = html.replace('http', 'hhttp') html = "<URL>" + addr + "\n\n" + html xz.str2txt(html, ausgabe) return html
def html2tbl(src,index): src = xz.txt2str(src) doc = soup(src,'lxml') # recommended res = [] for element in doc.find_all('table')[index]: try: lis = [ x.text for x in element ] except AttributeError: x = str(element) x = re.sub("<br/?>",'',x) x = re.sub(">[\s\n\r]+",'>',x) x = re.sub("[\s\n\r]+<",'<',x) # x = re.sub("<t[drh] .+?>",'',x) x = re.sub("</?t[drh]>","\t",x) x = re.sub("</?(span|a|sup|thead|tbody)>",'',x) # x = re.sub("<a href.+?>",'',x) x = re.sub("<img .+?>",'',x) x = re.sub("<span .+?>",'',x) # print( x ) lis = x.split("\t") res.append(lis) return res
def df2sache(df): df.to_csv(EIGENDATEI, sep="\t", encoding="utf8") return '/' + xz.txt2str(EIGENDATEI)
def getpid(prj=''): if prj == '': prj = xz.txt2str(bin4prj) prjs = xz.bin2obj(bin4lists) return prjs[prj]
def linkextractor(src): src = xz.txt2str(src) doc = soup(src,'lxml') # recommended links = [ element.get('href') for element in doc.find_all('a') ] return links