read file with multiple data per line

Eduardo edumlopes at
Tue Apr 14 09:15:18 CEST 2009

Hello all,

I googled a lot but couldn't find anything that i could consider a
possible solution (though i am fairly new to the language and i think
this is the main cause of my failure).

This is the beginning of the file i have to parse:

 Modified System
    2NHST1   C1   56   3.263   2.528  16.345

and this is the end:

    3.6539    6.4644   20.0000

This line has 7 formatted fields [5 digits integer, 5 digits
character, 5 digits character, 5 digits integer, three %8.3f fields]:

    2NHST1   C1   56   3.263   2.528  16.345

and this one has 3 %10.4f fields:
    3.6539    6.4644   20.0000

Those rules cannot be ignored or the programs i use to simulate and
analyze the results wont work.

This file describes the xyz coordinates and atom type of all the atoms
of the "system" i wish to simulate but i must sort all groups of
molecules together and that's what i planned to do with a python code.
I tried to accomplish this task using fortran wich is my main coding
skills, but it proved to be unstable so i decided to handle files
using a more apropriate languange while maintaining the number
crunching tasks written in fortran.

Thanks in advance and i apologise for eventual typos.

Eduardo Martins

More information about the Python-list mailing list