title: How to append values as a new coloumn to existing text file using python
body: <p>I tried to append values to a file. First I unpack values from i, j from frozen set and then I append those values to a file. Again I need to append x values in another column  rather than at the end of file. Kindly help me in this regard.</p>
  
  <pre><code>from __future__ import print_function
  
  from molmod import *
  
  from molmod.bonds import bonds
  
  import glob
  
  for file in glob.glob("*.xyz"):
  
    mol = Molecule.from_file(file)
    mol.graph = MolecularGraph.from_geometry()
  
    bos = list(mol.graph.edges)
  
    for edge in bos:
      i, j = edge
      print(i, j, file = open(file.replace('xyz', 'txt'), 'a'))
      s = list(mol.graph.orders)
      for x in s:
             print(x, file = open(file.replace('xyz', 'txt'), 'a'))
  </code></pre>
  
  <p>Output file:</p>
  
  <p>4 5</p>
  
  <p>1 2</p>
  
  <p>2 3</p>
  
  <p>1 4</p>
  
  <p>4 6</p>
  
  <p>6 7</p>
  
  <p>0 1</p>
  
  <p>8 9</p>
  
  <p>8 10</p>
  
  <p>10 11</p>
  
  <p>11 13</p>
  
  <p>13 15</p>
  
  <p>16 15</p>
  
  <p>16 17</p>
  
  <p>8 6</p>
  
  <p>10 2</p>
  
  <p>11 12</p>
  
  <p>13 14</p>
  
  <p>18 19</p>
  
  <p>18 20</p>
  
  <p>25 20</p>
  
  <p>25 27</p>
  
  <p>16 18</p>
  
  <p>27 15</p>
  
  <p>21 22</p>
  
  <p>21 23</p>
  
  <p>24 21</p>
  
  <p>20 21</p>
  
  <p>25 26</p>
  
  <p>27 28</p>
  
  <p>1.0</p>
  
  <p>2.0</p>
  
  <p>1.0</p>
  
  <p>2.0</p>
  
  <p>2.0</p>
  
  <p>1.0</p>
  
  <p>1.0</p>
  
  <p>1.0</p>
  
  <p>2.0</p>
  
  <p>1.0</p>
  
  <p>1.0</p>
  
  <p>1.0</p>
  
  <p>2.0</p>
  
  <p>Desired Output :</p>
  
  <p>4 5        1.0 </p>
  
  <p>1 2    2.0</p>
  
  <p>2 3    1.0</p>
  
  <p>1 4    2.0</p>
  
  <p>4 6    2.0</p>
  
  <p>6 7    1.0</p>
  
  <p>0 1    1.0</p>
  
  <p>8 9    1.0</p>
  
  <p>8 10       2.0</p>
  
  <p>10 11      1.0</p>
  
  <p>11 13      1.0</p>
  
  <p>13 15      1.0</p>
  
  <p>16 15      2.0</p>
  
  <p>16 17      1.0</p>
  
  <p>8 6    2.0</p>
  
  <p>10 2       2.0</p>
  
  <p>11 12      1.0</p>
  
  <p>13 14      1.0</p>
  
  <p>18 19      2.0</p>
  
  <p>18 20      1.0</p>
  
  <p>25 20      1.0</p>
  
  <p>25 27      1.0</p>
  
  <p>16 18      1.0</p>
  
  <p>27 15      2.0</p>
  
  <p>21 22      1.0</p>
  
  <p>21 23      1.0</p>
  
  <p>24 21      1.0</p>
  
  <p>20 21      1.0</p>
  
  <p>25 26      2.0</p>
  
  <p>27 28      1.0</p>