[Tutor] Extarcting data tables from a text file

Ruben Guerrero rudaguerman at gmail.com
Fri Nov 22 17:25:06 CET 2013


Dear tutor,

I am  a beginner in python and I need  your guidance to  write a python
script  to extract many nxn data tables of variable nunber of rows from a
text file as in the following example

      Condensed to atoms (all electrons):
              1          2          3          4          5          6
     1  Cl   0.000000   0.304108  -0.101110  -0.108502  -0.108502   0.024111
     2  C    0.304108   0.000000   0.515965   0.332621   0.332621  -0.004054
     3  C   -0.101110   0.515965   0.000000  -0.013334  -0.013334   0.352916
     4  H   -0.108502   0.332621  -0.013334   0.000000  -0.133436  -0.028924
     5  H   -0.108502   0.332621  -0.013334  -0.133436   0.000000  -0.028924
     6  H    0.024111  -0.004054   0.352916  -0.028924  -0.028924   0.000000
     7  H   -0.030910  -0.074027   0.364085  -0.053300   0.048704  -0.123402
     8  H   -0.030910  -0.074027   0.364085   0.048704  -0.053300  -0.123402
              7          8
     1  Cl  -0.030910  -0.030910
     2  C   -0.074027  -0.074027
     3  C    0.364085   0.364085
     4  H   -0.053300   0.048704
     5  H    0.048704  -0.053300
     6  H   -0.123402  -0.123402
     7  H    0.000000  -0.118520
     8  H   -0.118520   0.000000
 Mulliken atomic charges:

to other text  file with the numerical information in the table
 concatenated by columns. The phrases in red always delimite the tables in
the original file. In the python generated file I need the following:   a
text flag (maybe  a line with the "O" charanter) delimiting each table, a
second line with the total number of rows (atoms) in the table followed by
a line with the ordered string of chemical symbols separated by a silgle
space.

My aim is load the numerical data from this file  to a c++ program to
process this information.

Thanks in advance.

-Ruben.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131122/b4aa577d/attachment.html>


More information about the Tutor mailing list