Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help With a Script
#7
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.

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
Reply


Messages In This Thread
Need Help With a Script - by SunWers - Jan-05-2021, 05:42 PM
RE: Need Help With a Script - by SunWers - Jan-05-2021, 05:49 PM
RE: Need Help With a Script - by buran - Jan-05-2021, 06:34 PM
RE: Need Help With a Script - by SunWers - Jan-05-2021, 08:56 PM
RE: Need Help With a Script - by buran - Jan-05-2021, 09:00 PM
RE: Need Help With a Script - by SunWers - Jan-05-2021, 09:43 PM
RE: Need Help With a Script - by SunWers - Jan-07-2021, 03:26 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020