Store Data Which Is An Output Of Python Program In Excel File
Solution 1:
you could just do this on commandline
test.py>output.csv
This will put all the data in a csv file which can then be read by excel
Solution 2:
Start here - https://docs.python.org/3.5/library/csv.html. This is standard library for writing csv
files. For Excel files you can try openpyxl
, which have to be installed separately.
Solution 3:
Ok so you can use openpyxl.
This is one way to proceed. I assume that each line of output that you have is stored as a variable or something. Maybe something like this and you loop through it:
varCol1 = "ענת מאירה"varCol2 = "2016-07-25"varCol3 = "0546515015"varCol4 = "בוטוקס ועיבוי שפתיים"
So to get each of those variables written to a spreadsheet you could do something like this:
importopenpyxlwb= openpyxl.Workbook()
sheet = wb.active
sheet['A1'] = varCol1
sheet['B1'] = varCol2
sheet['C1'] = varCol3
sheet['D1'] = varCol4
wb.save('example_excel.xlsx')
This type of thing could be implemented in a loop and you could iterate through the row number to fill the sheet with the data that you want. For more help check out This Link.
Post a Comment for "Store Data Which Is An Output Of Python Program In Excel File"