On Tue, Jul 12, 2011 at 5:44 AM, Peter Otten <__pete...@web.de> wrote:
> Edgar Almonte wrote:
>
>> thanks emile i understand exactly what you explain me but i was unable
>> to accomplish it ( too noob in python ) but i solved the problem with
>> this code
>> http://pastebin.com/4A6Jz4wZ
>>
>> i will try do what you suggest me anyway but that will tomorrow ,
>> tonight i done and i feel good :D
>
> When you're done compare it to the one below:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> import csv
>
> def sortkey(row):
>    if float(row[1]):
>        return row[1], True
>    else:
>        return row[2], False
>
> with open("infile.txt", "rb") as instream:
>    rows = sorted(csv.reader(instream, delimiter="|"), key=sortkey)
>
> with open("outfile.txt", "wb") as outstream:
>    csv.writer(outstream, delimiter="|").writerows(rows)
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
This look aweasome i will try it later , thanks
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to