filename = r"C:\Users\EXCEL_1.xlsx"
book = openpyxl.load_workbook(filename)
# sheet extract
sheet = book.worksheets[0]
# EXCEL_1 LIST
data = []
for row in sheet.rows:
data.append([
row[0].value,
' ',
row[3].value,
row[4].value,
row[5].value,
row[6].value,
row[7].value,
row[8].value,
])
data = data[1:]
# EXCEL_2
wb = load_workbook(r"C:\Users\EXCEL_2.xlsx")
ws = wb.active
# excel input
for n, datalist in enumerate(data, 3):
for n2, i in enumerate(datalist, 1):
cell = ws.cell(row = n, column = n2).value = i
# save
wb.save("Final Product.xlsx")
wb.close()
As above, I wrote a code to enter the contents of EXCEL_2 in EXCEL_1.
I will implement this as a GUI and make it an EXE file finally.
When you run a file, how do you write code to derive results by selecting different EXCEL files for "EXCEL_1" and "EXCEL_2" regardless of path?
I ask for your help.
Sorry if I cannot understand your question. I will try to add a couple of pieces of information and hope it is useful.
You may be asking how the file name can differ in your program.
wb = load_workbook(r'C:\Users\EXCEL_2.xlsx')
is the same as:
name = r'C:\Users\EXCEL_2.xlsx'
wb = load_workbook(name)
You may be asking how to make the GUI. You might want to start looking at the 'cookbook' of simple programs. The FileBrowse
and FolderBrowse
controls might be useful.
To make the question more answerable, try cutting down the code to smallest portion that you want to make better. Programming looks daunting at first, but it gets better.
Keep on coding. Keep notes.