Phillip T.
Germany
19 Posts |
Posted - 03/11/2022 : 08:31:13 AM
|
Hi,
i want to extract some time data from ANSI encoded files. My code works in pycharm with python 3.8 as interpreter but running it in origin gives me following error:
Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\AG Over\Desktop\Python Projects\Origin com test\new_Import_with IR extract.py", line 57, in <module> line = line.decode('ANSI') LookupError: unknown encoding: ANSI
My code is:
with open(IR_path, 'rb') as curIR:
for line in curIR: line = line.decode('ANSI') TIMpos = line.find("TIM")
if TIMpos != -1 and line[TIMpos+10] == ":": #print(TIMpos) curIRtime_str = line[TIMpos-12:TIMpos-2]+ " " + line[TIMpos+8:TIMpos+16] print(jj) print(curIRtime_str) curIRtime = datetime.strptime(curIRtime_str, "%d/%m/%Y %H:%M:%S") timemdelta = curIRtime - MFC_start_time timemdelta = timemdelta.total_seconds() IRtimes.append(timemdelta) print(c) print(IRtimes[c]) c +=1 break curIR.close()
I read online Python changed some things about how it handles encoding or something at some point but this stuff is way above my paygrade. Could someone enlighten me about what is going on or better tell me what magic buttons I have to push so this goes away? Thanks.
Regards, Phillip |
|