Olli Virta escribió:
Hi!
I have a textfile (job.txt) that needs modifying. The structure of this file is like this: AAA1...
BBB1...
CCC1...
AAA2...
BBB2...
CCC2...
etc...
Question is how can I turn this all to a textfile (done.txt) that is suppose to look like this: AAA1...BBB1...CCC1...
AAA2...BBB2...CCC2...
etc.
Thanks! OV ------------------------------------------------------------------------

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
hi...

i dont think this is the best way of doing it, but you can have an idea by reading the code:

some_file="""AAA1...
BBB1...
CCC1...
AAA2...
BBB2...
CCC2..."""

some_tuple=some_file.split()

def change(some_tuple):
   temp=""
   temp2=""
   for x in some_tuple:
       if "1" in x:
           temp+=x
       else:
           temp2+=x
   done= temp +"\n" +temp2
   return done

done_file=change(some_tuple)

is not perfect but you can get the idea..
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to