Jan-07-2021, 03:26 AM
I think I'm finally getting closer to what I'm trying to achieve. As mentioned above I have two worksheets, one is an import file and the other is a blank report to add the import data. This is the script I have now.
Only problem I have now is that it's pulling all data from the import sheet. I need all rows but I want specific columns. I'm thinking I need to change the, "for j in range (1, sheet1.max_column+1)" to look for those specific columns. I'm not sure how to do that.... The columns I need is A:F and O:V. How would I do this?
Thanks,
Veronica
from openpyxl import load_workbook wb1 = load_workbook('Cutter A - Import.xlsx') wb2 = load_workbook('Weekly-temp1.xlsx') sheet1 = wb1.get_sheet_by_name('Cutter A - ImportFilev1') sheet2 = wb2.get_sheet_by_name('Cutter A Import') for i in range(1,sheet1.max_row+1): for j in range(1,sheet1.max_column+1): sheet2.cell(row=i,column=j).value = sheet1.cell(row=i,column=j).value wb2.save('Weekly-temp1.xlsx')
Only problem I have now is that it's pulling all data from the import sheet. I need all rows but I want specific columns. I'm thinking I need to change the, "for j in range (1, sheet1.max_column+1)" to look for those specific columns. I'm not sure how to do that.... The columns I need is A:F and O:V. How would I do this?
Thanks,
Veronica