>For line in array:
>   print ' '.join( line )

Sorry this it should be:
for line in processed:
   print ' '.join( line )

This worked for me. 
>>> pprint.pprint( processed) # Note in the email I have changed the format but 
>>> not the data
[['ATOM',  '2',  'H20',  'CUR',  '1',  '30.338',  '28.778',  '-6.812',  '1.00', 
 '0.00'], 
 ['ATOM',  '4',  'C20',  'CUR',  '1',  '31.394',  '28.922',  '-7.039',  '1.00', 
 '0.00'],
 ['ATOM',  '5',  'C19',  'CUR',  '1',  '31.790',  '29.357',  '-8.323',  '1.00', 
 '0.00']]
>>> pprint.pprint( sorted( processed, key= lambda x: mapping.get( x[2], 0 ) ) ) 
# I use sorted instead of processed in case it did not sort correctly (that way 
I still have the original list)
[['ATOM',  '5',  'C19',  'CUR',  '1',  '31.790',  '29.357',  '-8.323',  '1.00', 
 '0.00'],
 ['ATOM',  '4',  'C20',  'CUR',  '1',  '31.394',  '28.922',  '-7.039',  '1.00', 
 '0.00'],
 ['ATOM',  '2',  'H20',  'CUR',  '1',  '30.338',  '28.778',  '-6.812',  '1.00', 
 '0.00']]

You should note, that I just used "print" I did not write to file. You will 
need to actually create/open a file, run through the list (e.g. processed) and 
write to the file, and then finally close it.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423


From: tutor-bounces+ramit.prasad=jpmorgan....@python.org 
[mailto:tutor-bounces+ramit.prasad=jpmorgan....@python.org] On Behalf Of lina
Sent: Thursday, September 29, 2011 11:39 AM
To: tutor
Subject: Re: [Tutor] map one file and print it out following the sequence



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to