Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16448

How to use python to edit a column with linked data?

$
0
0

I have a text data file containing multi-columns, rows and sections. Herein, I want to delete rows which their 5th or 6th or 7th columns larger than 50.

Challenges are:

  1. In 'Atoms' section, the first column is called 'Atom_id'. This 'Atom_id' is used in the 3rd or 4th columns of 'Bond' section. So deleted 'atom_id' should also be deleted at 'Bond' section, if it is available at its 3rd or 4th column.
  2. Updating 'Atom_id' and 'Bond_id' to be continuous. But, the problem is about 3rd or 4th columns of 'Bond' section, which should be updated correspondingly.

Any comments or suggestions will be highly appreciated,Thanks in advance.

Here is the my minimized data file.

#Atoms#Atom_id    molecules_id    atom_type   charge  x_coor  y_coor  z_coor       1       1     2    -0.834           60.243           56.013           55.451         2       1     1     0.417           1.061            6.406            5.263         3       1     1     0.417           3.513            2.071             5.526         4       2     2    -0.834             4.14           6.861            5.328         5       2     1     0.417            4.322            6.96            5.317         6       2     1     0.417            3.303           1.922            4.912         7       3     2    -0.834           12.756           53.344            3.856         8       3     1     0.417           12.527           53.366            4.833         9       3     1     0.417           12.039           53.747            3.454        10       4     2    -0.834           1.402            7.122           13.392   #Bonds #Bond_id   bond_type   atom_id atom_id       1       2       1       2           2       2       1       3           3       2       4       5         4       2       4       6          5       2       7       8          6       2       7       9          7       2      10      11          8       2      10      12          9       2      13      14         10       2      13      15          11       2      16      17 

It seems it would be better to clean the data and separate these sections into two different files. Is it easier to write the script for separated sections?


Viewing all articles
Browse latest Browse all 16448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>