title: How to insert some field data into a data source file after reading from another text file
body: <p>The following script is working perfectly. It computes the percentages changes from sourcedata.txt against updatedata.txt. However, I wanted to insert into sourcedata.txt by appending the read values from the updatedata.txt.</p>
  <pre><code>s1 = open(&quot;sourcedata.txt&quot;, &quot;r&quot;)
  u1 = open(&quot;updatedata.txt&quot;, &quot;r&quot;)
  
  i = 0
  item = 0
  for line1 in s1:
  i += 1
  st1 = list(line1.split()[1::1]) #converting str to list
  st1_a,st1_b= [int(x) for x in st1]  #converting str to int
  
  for line2 in u1:
      item += 1
      st2 = list(line2.split()[1::1])
      st2_a,st2_b= [int(x) for x in st2]
      print (&quot;Item%s &quot; % item + &quot;%s&quot; % st1 + &quot; -&gt; &quot; + &quot;%s&quot; % st2)
  
      print (f&quot; Change: { round(((st2_a - st1_a)/st1_a)*100,2)}%  { round(((st2_b - st1_b)/st1_b)*100,2)} &quot;)  #you can make seprate function to calculate to percentage change , round for rounding the number
      print()
  # closing files
  s1.close()                                  
  u1.close()
  </code></pre>
  <p>Current Output and Wanted Modification Result</p>
  <pre><code>Current Output:
   Item1 ['10', '30'] -&gt; ['120', '375']
   Change: 1100.0%  1150.0 
   Item2 ['10', '30'] -&gt; ['545', '550']
   Change: 5350.0%  1733.33 
   Item3 ['10', '30'] -&gt; ['750', '690']
   Change: 7400.0%  2200.0 
   
  sourcedata.txt &lt;- Initial Data File
   item1 10 30 1 1
   item2 25 50 2 2
   item3 50 75 3 3
  
  updatedata.txt &lt;- File that contains update
   item1 120 375
   item2 545 550
   item3 750 690
  
  sourcedata.txt &lt;- This is the updated file after running the script
   item1 10 30 120 375   &lt;- replace 1 1 with 120 375
   item2 25 50 545 550   &lt;- replace 2 2 with 545 550
   item3 50 75 750 690   &lt;- replace 3 3 with 750 690
  </code></pre>