I am currently creating an account management program where account details are stored in a .csv file, the user will enter the username of the account they want to delete but when I go delete a line it doesn't work correctly, if I use the "r+" mode it wont actually do anything and when I use "w" mode it will delete the entire file when i try to remove a single line.
Here is the code below for the delete function:
delUserName = input("enter the username of the account you want to delete")
with open(filename, 'r+') as csvFile:
reader = csv.reader(csvFile, delimiter=",")
writer = csv.writer(csvFile, delimiter=",")
for rows in reader:
if rows[1] == delUserName:
writer.writerow("")
The csv file is setup as 1,username,password so rows[0] would be index, rows[1] would be username and rows[2] would be password
Any help will be much appreciated.