Note that there are some explanatory texts on larger screens.

plurals
  1. POPython - Write to Excel Spreadsheet
    primarykey
    data
    text
    <p>I am new to Python. I need to write some data from my program to a spreadsheet. I've searched online and there seems to be many packages available (xlwt, XlsXcessive, openpyxl). Others suggest to write to a csv file (never used csv &amp; 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><img src="https://i.stack.imgur.com/Ih3fa.png" alt="enter image description here"></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? Thanks.</p> <p>P.S. I am running Windows 7 but I won't necessarily have Office installed on the computers running this program.</p> <p><strong>EDIT</strong></p> <pre><code>import xlwt x=1 y=2 z=3 list1=[2.34,4.346,4.234] book = xlwt.Workbook(encoding="utf-8") sheet1 = book.add_sheet("Sheet 1") sheet1.write(0, 0, "Display") sheet1.write(1, 0, "Dominance") sheet1.write(2, 0, "Test") sheet1.write(0, 1, x) sheet1.write(1, 1, y) sheet1.write(2, 1, z) sheet1.write(4, 0, "Stimulus Time") sheet1.write(4, 1, "Reaction Time") i=4 for n in list1: i = i+1 sheet1.write(i, 0, n) book.save("trial.xls") </code></pre> <p>I wrote this using all your suggestions. It gets the job done but it can be slightly improved. How do I format the cells created in the for loop (list1 values) as scientific or number? I do not want to truncate the values. The actual values used in the program would have around 10 digits after the decimal.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload