non-uniform string substituion
steve at holdenweb.com
Thu Feb 14 02:25:23 CET 2008
Horacius ReX wrote:
> I have a file with a lot of the following ocurrences:
> distributed randomly in a file. I need to convert each of this
> ocurrences to:
> so basically I add "_1" at the end of each ocurrence.
> I thought about using sed, but as each "root" is different I have no
> clue how to go through this.
> Any suggestion ?
> Thanks in advance.
First you have to tell us what characterizes the lines you want to
process. For example, if the only requirement is that they begin with
"denmark.handa" you could say
for line in sys.stdin:
line = line[:-1]+"_1\n"
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list