title: Is it possible to inject a number into excel at every 1 minute interval using Python?
body: <p>Currently, I have a code that updates an excel sheet every 5 seconds. It will print</p>
   <p>0 400 800 800 800
   <p>1 400 800 800 800
   <p>2 400 800 800 800
  <p>What I am trying to figure out is how do I add in a random number into that list at every 1min interval, for example,</p>
   <p>0 400 800 800 800
   <p>1 **425** 800 800 800
   <p>2 400 800 800 800
  <p>The code shown here is the current code I am having and was wondering if anyone can help me out here, thanks so much :).</p>
  <pre><code>import csv
  import random
  import time
  
  x_value = 0
  total_1 = 400 #voltage
  total_2 = 800 #current(1)
  total_3 = 800 #current(2)
  total_4 = 800 #current(3)
  
  fieldnames = [&quot;Timestamp&quot;, &quot;Voltage&quot;, &quot;[L1] Current(1)&quot;, &quot;[L1] Current(2)&quot;, &quot;[L1] Current(3)&quot;]
  
  with open('test 4.0.csv', 'w') as csv_file:
      csv_writer = csv.DictWriter(csv_file, fieldnames = fieldnames)
      csv_writer.writeheader()
      
  while True:
      with open('test 4.0.csv', 'a') as csv_file:
          csv_writer = csv.DictWriter(csv_file, fieldnames = fieldnames)
          
          info = {
              &quot;Timestamp&quot;: x_value,
              &quot;Voltage&quot;: total_1,
              &quot;[L1] Current(1)&quot;: total_2,
              &quot;[L1] Current(2)&quot;: total_3,
              &quot;[L1] Current(3)&quot;: total_4
              }
          csv_writer.writerow(info)
          print(x_value, total_1, total_2, total_3, total_4)
          
          x_value += 1
  
      time.sleep(5) #controls the speed of the loop eg. 1 = 1sec
  </code></pre>