title: How to write to an Excel spreadsheet using Python?
body: <p>I need to write some data from my program to an Excel spreadsheet. I've searched online and there seem to be many packages available (xlwt, XlsXcessive, openpyxl). Others suggest writing to a .csv file (never used CSV and don't really understand what it is).</p>
  <p>The program is very simple. I have two lists (float) and three variables (strings). I don't know the lengths of the two lists and they probably won't be the same length.</p>
  <p>I want the layout to be as in the picture below:</p>
  <p><a href="https://i.stack.imgur.com/Ih3fa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ih3fa.png" alt="Layout sample" /></a></p>
  <p>The pink column will have the values of the first list and the green column will have the values of the second list.</p>
  <p>So what's the best way to do this?</p>
  <p>I am running Windows 7 but I won't necessarily have Office installed on the computers running this program.</p>
  <pre class="lang-py prettyprint-override"><code>import xlwt
  
  x=1
  y=2
  z=3
  
  list1=[2.34,4.346,4.234]
  
  book = xlwt.Workbook(encoding=&quot;utf-8&quot;)
  
  sheet1 = book.add_sheet(&quot;Sheet 1&quot;)
  
  sheet1.write(0, 0, &quot;Display&quot;)
  sheet1.write(1, 0, &quot;Dominance&quot;)
  sheet1.write(2, 0, &quot;Test&quot;)
  
  sheet1.write(0, 1, x)
  sheet1.write(1, 1, y)
  sheet1.write(2, 1, z)
  
  sheet1.write(4, 0, &quot;Stimulus Time&quot;)
  sheet1.write(4, 1, &quot;Reaction Time&quot;)
  
  i=4
  
  for n in list1:
      i = i+1
      sheet1.write(i, 0, n)
  
  book.save(&quot;trial.xls&quot;)
  </code></pre>
  <p>I wrote this using all your suggestions. It gets the job done but it can be slightly improved.</p>
  <p>How do I format the cells created in the for loop (<code>list1</code> values) as scientific or number?</p>
  <p>I do not want to truncate the values. The actual values used in the program would have around 10 digits after the decimal.</p>