I'm still fairly new to coding, so I'm sure that there are easier or prettier ways to write the following script. The script runs and the new sheets are created within the workbook, however, the data is not copying from 'sheet1' to the second sheet
I've tried googling and reading other threads on Stack Overflow, but none seem to answer the question
import os, csv, glob, shutil, pandas as pd, numpy as np, openpyxl as opyx
path_to_combined_file = c:\\somefilepath here\\
filepath = path_to_combined_file + 'NSW.xlsx'
unaided_brand_awareness = pd.read_excel(filepath)
from openpyxl import load_workbook
wb = load_workbook(filepath)
wb.create_sheet('unaided_brand_awareness')
wb.create_sheet('aided_brand_awareness')
wb.create_sheet('favourite_stations')
worksheet1 = wb['Sheet1']
worksheet2 = wb['unaided_brand_awareness']
for i in range (1,2000):
for j in range(1, worksheet1.max_column + 1):
worksheet2.cell(row = i, column = j).value = worksheet1.cell(row = i, column = j).value
wb.save(filepath)
The code SHOULD create the following sheets 'unaided brand awareness', 'aided brand awareness' and 'favourite stations' and then copy the data from the sheet titled 'Sheet1' to the sheet titled 'unaided brand awareness'
Ideally, it would be great to have the data from 'Sheet1' copied to all the sheets within the workbook.
Also, i probably should note that the number of cells contained within 'Sheet1' will differ from case to case.