So far I have been able to copy data from only one workbook using the code below
Expand|Select|Wrap|Line Numbers
- import openpyxl as xl
- path1 ='C:\\Users\\f65651\data\\cq1.xlsx' #One of the doc
- #path3 = 'C:\\Users\\f65651\data\\cq2.xlsx'
- path2='C:\\Users\\f65651\\data\\Results.xlsx' #Master Workbook
- wb1 = xl.load_workbook(filename=path1)
- ws1 = wb1.worksheets[0]
- wb2= xl.load_workbook(filename=path2)
- ws2= wb2.worksheets[0]
- for row in ws1:
- for cell in row:
- ws2[cell.coordinate].value=cell.value
- wb2.save(path2)
I have tried storing them into dataframe but it messes up the format in the Result sheet, so using df is out of it! or if there is any other way around. Please kindly suggest.