Re: SAX unicode and ascii parsing problem

2010-12-01 Thread Adam Tauno Williams
On Tue, 2010-11-30 at 12:28 -0800, goldtech wrote: > I'm trying to parse an xml file using SAX. About half-way through a > file I get this error: > Traceback (most recent call last): > File "C:\Python26\Lib\site-packages\pythonwin\pywin\framework > \scriptutils.py", line 325, in RunScript >

Re: SAX unicode and ascii parsing problem

2010-12-01 Thread Ulrich Eckhardt
goldtech wrote: > I tried this but nothing changed, I thought this might convert it and > then I'd paerse the new file - didn't work: > > uc = open(r'E:\sc\ppb4.xml').read().decode('utf8') > ascii = uc.decode('ascii') > mex9 = open( r'E:\scrapes\ppb5.xml', 'w' ) > mex9.write(ascii) This doesn't m

Re: SAX unicode and ascii parsing problem

2010-11-30 Thread Stefan Behnel
goldtech, 30.11.2010 22:15: Think I found it, for example: line = 'my big string' line.encode('ascii', 'ignore') I processed the problem strings during parsing with this and it works now. That's not the right way of dealing with encodings, though. You should open the file with a well defined

Re: SAX unicode and ascii parsing problem

2010-11-30 Thread Justin Ezequiel
can't check right now but are you sure it's the parser and not this line d.write(csv+"\n") that's failing? what is d? -- http://mail.python.org/mailman/listinfo/python-list

Re: SAX unicode and ascii parsing problem

2010-11-30 Thread goldtech
snip... > > I'm just as stumped as I was when you first asked this question 13 > minutes ago. ;-) > > regards >  Steve > snip... Hi Steve, Think I found it, for example: line = 'my big string' line.encode('ascii', 'ignore') I processed the problem strings during parsing with this and it works n

Re: SAX unicode and ascii parsing problem

2010-11-30 Thread Steve Holden
On 11/30/2010 3:43 PM, goldtech wrote: > Hi, > > I'm trying to parse an xml file using SAX. About half-way through a > file I get this error: > > Traceback (most recent call last): > File "C:\Python26\Lib\site-packages\pythonwin\pywin\framework > \scriptutils.py", line 325, in RunScript > e

SAX unicode and ascii parsing problem

2010-11-30 Thread goldtech
Hi, I'm trying to parse an xml file using SAX. About half-way through a file I get this error: Traceback (most recent call last): File "C:\Python26\Lib\site-packages\pythonwin\pywin\framework \scriptutils.py", line 325, in RunScript exec codeObject in __main__.__dict__ File "E:\sc\b2.py",

SAX unicode and ascii parsing problem

2010-11-30 Thread goldtech
Hi, I'm trying to parse an xml file using SAX. About half-way through a file I get this error: Traceback (most recent call last): File "C:\Python26\Lib\site-packages\pythonwin\pywin\framework \scriptutils.py", line 325, in RunScript exec codeObject in __main__.__dict__ File "E:\sc\b2.py",