The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Python
 ANSI encoding
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Phillip T.

Germany
19 Posts

Posted - 03/11/2022 :  08:31:13 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

minimax

351 Posts

Posted - 04/27/2022 :  02:36:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

What python package needs to be installed to run your script?

PS, would you mind to modify the scripts in your original post to add the code block so that indent is more read-able?

There is a "Insert Code" button on the Format toolbar when editing.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000