Something simple like following will work for files
that fit in memory:
def onlyascii(char):
if ord(char) < 48 or ord(char) > 127: return ''
else: return char
f=open('filename.ext','r')
data=f.read()
f.close()
filtered_data=filter(onlyascii, data)
For larger files you will need to loop and read
the data in chunks.
-Larry Bates
----------------------------
"omission9" <ru******@salemstate.edu> wrote in message
news:de**************************@posting.google.c om...
I have a text file which contains the occasional non-ascii charcter.
What is the best way to remove all of these in python?