formatting file

Peter Hansen peter at engcorp.com
Wed Apr 6 10:24:15 EDT 2005


SPJ wrote:
> I have a file with the following format:
> 
> test1    1.1-1   installed
> test1    1.1-1   update
> test2    2.1-1   installed
> test2    2.1-2   update
> 
> I want the file to be formatted in the following way:
> 
> test1    1.1-1   1.1-2
> test2    2.1-1   2.1-2

Please verify that you made an error about the second
version value for "test1": the before (1.1-1) and
the after (1.1-2) values do not match.

Also, is it fair to assume the file is guaranteed
to contain even numbers of lines, always with both
an "installed" line and an "update" line, and that
the order is as shown above, etc...  in other words,
how robust does the solution need to be?

(You might also show a little bit of your own attempt,
if nothing else so we don't get the idea this is
homework that we're doing for you. :-) )

-Peter



More information about the Python-list mailing list