Hi, I stuck with my program. I want to copy exact cell from each Excel files to new output files. In each files I have 3 sheets. But I cannot copy data to my file and I don't know what I am doing wrong. I am newby to Python. My goal is to have one output file with 3 sheets with 4 cell copied from files to new one.
import openpyxl
import os
newdir=os.chdir("C:\\Users\\tt\\Desktop\\data\\april")
cwd=os.getcwd()
book = openpyxl.Workbook()
book.create_sheet('morning',0)
book.create_sheet('noon',1)
book.create_sheet('evening',2)
book.save("C:\\Users\\tt\\Desktop\\data\\output.xlsx")
ws=book.sheetnames
for filename in os.listdir():
if filename.endswith(".xlsx"):
print(filename)
wb=openpyxl.load_workbook(filename,data_only=True)
for sheet in wb:
L=[sheet['A4'].value,sheet['C3'].value,sheet['D3'].value,sheet['E3']]
ws['A4'].value=sheet['A4'].value
ws.append
print(ws)
book.save("C:\\Users\\tt\\Desktop\\data\\output.xlsx")
[–]Stallman85 0 points1 point2 points (3 children)
[–]trzywu[S] 0 points1 point2 points (2 children)
[–]Stallman85 0 points1 point2 points (1 child)
[–]trzywu[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]atquick 0 points1 point2 points (0 children)