On 22/11/2013 16:25, Ruben Guerrero wrote:
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.


I'm sorry but we don't write code for you here. I suggest that you start out by reading the tutorial here http://docs.python.org/3/tutorial/index.html, try writing something and when and if you run into problems please feel free to get back to us.

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to