Count and replacing strings a texfile

puckoh at my-deja.com puckoh at my-deja.com
Mon Jan 22 16:42:21 EST 2001


Hello.

This is a probably basic question.
I have a textfile about 120k large, and there is several strings in it
which I must replace.
The strings are named "%id%" and the number of strings are unknown.

First, I need to count them all.
Then I must replace every one of them with a incrementing number.
Like the first %id% is replaced with 1, the second with 2 etc.

I've been told that this is a perfect job for Perl, but I don't
understand Perl.
I merely understand Python. Well, I think I got the basics anyway. :)


Anyone care to help me out for a minute to suggest what to do?
Any pointers to examples are alot appreciated.

Thanks.

/Andreas


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list