I'm relatively new to python and have picked it up as a hobby. I've been trying to make a password manager but to save variables I need to access excel files and copy variable data into the next empty row in columns A and B.
I have currently tried this to no avail:
value3 = v3.get()
value2 = v2.get()
folderPath = "C:\Password Manager"
if not os.path.exists(folderPath):
os.makedirs(folderPath)
filename = "Encrypted_Passwords.xlsx"
filePath = os.path.join(folderPath, filename)
print(filePath)
open(filePath, "w+")
wb = openpyxl.load_workbook(filePath)
ws = wb.active
for i in range (ws.max_row):
if ws.cell(row=i, column=1).value == None:
ws.cell(row=i, column=1).value = value2
ws.cell(row=i, column=2).value = value3
Any help would be greatly appreciated, have been trying to figure this out for days.

Here is the openpyxl doc on worksheet.max_row: worksheet.max_row
If you want to write value to empty row, you need to start from
rowIndex = ws.max_row + 1. not looping from0tows.max_row.e.g below will work:
If you really need a for loop to check each row, you can just change
for i in range(ws.max_row)tofor i in range(1, 1000):If you need to input a list of passwords into column A and column B alternatively, you can try below for loop: