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
 All Forums
 Origin Forum for Programming
 Forum for Python
 ANSI encoding

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Phillip T. 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
1   L A T E S T    R E P L I E S    (Newest First)
minimax Posted - 04/27/2022 : 02:36:46 AM
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.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000