mirror of
https://github.com/FAUSheppy/ths-datenlogger
synced 2025-12-06 04:11:34 +01:00
additional fallback for legacy txt
This commit is contained in:
@@ -294,7 +294,11 @@ def csvread_txt(path,datapoints,pt,ph,pd,qtTextBrowser):
|
|||||||
timeutils.time_from_csv,
|
timeutils.time_from_csv,
|
||||||
timeformat="%d-%m-%Y_%H:%M")
|
timeformat="%d-%m-%Y_%H:%M")
|
||||||
except (UnicodeError, IndexError):
|
except (UnicodeError, IndexError):
|
||||||
count = csvread_txt_fallback(path,datapoints,pt,ph,pd)
|
try:
|
||||||
|
count = csvread_txt_fallback(path,datapoints,pt,ph,pd)
|
||||||
|
except (IndexError, ValueError):
|
||||||
|
count = csvread_txt_legacy(path,datapoints,pt,ph,pd)
|
||||||
|
|
||||||
|
|
||||||
qtTextBrowser.append(de.info_ig_lines.format(count))
|
qtTextBrowser.append(de.info_ig_lines.format(count))
|
||||||
|
|
||||||
@@ -319,3 +323,26 @@ def csvread_txt_fallback(path,datapoints,pt,ph,pd):
|
|||||||
timeutils.time_from_csv,
|
timeutils.time_from_csv,
|
||||||
timeformat="%d-%m-%Y_%H:%M")
|
timeformat="%d-%m-%Y_%H:%M")
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
def csvread_txt_legacy(path,datapoints,pt,ph,pd):
|
||||||
|
count = 0
|
||||||
|
with open(path) as f:
|
||||||
|
for l in f:
|
||||||
|
if any(s in l for s in [">>", "----", "Uhrzeit"]):
|
||||||
|
count += 1
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
row_arg = list(map(lambda s:s.replace(" ","").replace(",","."),l.split("\t")))
|
||||||
|
row = {"temp":None,"hum":None,"taupunkt":None,"datetime":None}
|
||||||
|
|
||||||
|
# datetime, cutoff :SS at the end #
|
||||||
|
row["datetime"] = "{date}_{time}".format(date=row_arg[1], time=row_arg[2])[:-3]
|
||||||
|
row["temp"] = float(row_arg[3])
|
||||||
|
row["hum"] = float(row_arg[4])
|
||||||
|
row["taupunkt"] = float(row_arg[5])
|
||||||
|
parse_line(datapoints, row, 'datetime',
|
||||||
|
[('temp',pt), ('hum',ph), ('taupunkt',pd)],
|
||||||
|
timeutils.time_from_csv,
|
||||||
|
timeformat="%d-%m-%Y_%H:%M")
|
||||||
|
|
||||||
|
return count
|
||||||
|
|||||||
Reference in New Issue
Block a user