cleaning up an ASCII file?
tjreedy at udel.edu
Wed Jun 10 16:41:27 EDT 2009
Nick Matzke wrote:
> Hi all,
> So I'm parsing an XML file returned from a database. However, the
> database entries have occasional non-ASCII characters, and this is
> crashing my parsers.
> Is there some handy function out there that will schlep through a file
> like this, and do something like fix the characters that it can
> recognize, and delete those that it can't? Basically, like the BBEdit
> "convert to ASCII" menu option under "Text".
Lookup str.maketrans and str.translate, which can leave alone, replace,
or delete each char.
More information about the Python-list