[Tutor] replace windows quote

Magnus Lycka magnus@thinkware.se
Fri Jan 10 08:00:02 2003


At 13:25 2003-01-10 +0100, Pietro Ciuffo wrote:
>I have to replace - inside a text file - a quote inserted
>by Word X Windows with a simple plain quote.
>The problem is to match the 'Win' quote: if I open the file in vim, I
>see a '~R' blue sign, if I do cat -A, the output is a 'M-^R' sign.
>Anyone could help me?

Open the file in Python instead. Of course!

Then you have all the python tools to inspect with.
It might be enough to just do:

data = file('myfilename').read()
print data
print repr(data)

If that wasn't enough, you might be helped by

for x in data:
     print ord(x), x

If the file is big, use slices "data[100:120]" to pick
out the relevant piece.

If you don't know how to find the right spot, use find.

print data.find('some known text')



-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se