I wrote a python code to get a string output as following code segment.
a = "First "
b = "Second"
c = a+b
I need to save value of c in a excel file every time I run that program.How can I do that?
I wrote a python code to get a string output as following code segment.
a = "First "
b = "Second"
c = a+b
I need to save value of c in a excel file every time I run that program.How can I do that?
from openpyxl import Workbook
a = "First "
b = "Second"
c = a+b
file_path= "temp.xlsx"
wb = Workbook()
ws = wb.active
ws.append(c)
wb.save(file_path)
Make first your excel file named test.xlsx Then use this code to load your file and write to it:
from openpyxl import load_workbook
filename= 'test.xlsx'
wb = load_workbook(filename)
file = wb.active
file.append(["data"])
wb.save(filename=filename)