[Tutor] compare and arrange file

Steve Willoughby steve at alchemy.com
Tue Jul 12 02:22:00 CEST 2011


On 11-Jul-11 17:18, Edgar Almonte wrote:
> this is just one time thing and the value don't get repeat

Then you could make a single loop over the input lines, building two
dictionaries as you go:
   * one that maps column 2's value to the rest of that line's data
   * and one that does this for column 3's value.

Now run through the column 2 data you saved, print that data row,
then look up the value in the other dictionary and print that after it.

>
> On Mon, Jul 11, 2011 at 7:55 PM, Steve Willoughby<steve at alchemy.com>  wrote:
>> On 11-Jul-11 16:50, Edgar Almonte wrote:
>>>
>>> Thanks for the hints , what i want accomplish is sort the line by the
>>> same value in the column 2 and 3
>>>
>>> i mean the line with the same value in the 2 get together with the
>>> line in the same value in column 3
>>
>> What if the same value appears more than once?  Does it matter which ones
>> you match up?  If so, how do you decide?
>>
>> --
>> Steve Willoughby / steve at alchemy.com
>> "A ship in harbor is safe, but that is not what ships are built for."
>> PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>


-- 
Steve Willoughby / steve at alchemy.com
"A ship in harbor is safe, but that is not what ships are built for."
PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C


More information about the Tutor mailing list