Hello I'm a beginner in Python and I would like to know how to delete csv data using user input without having to use another file as a output. My code is:
import csv
mark = input("What would you like to delete")
with open('first.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file)
for line in csv_reader:
if str(line[0]) != str(mark):
pen = open('first.csv', 'a')
pen.write(line[0] + '\n')
print('sucessfully deleted')
Currently all the file does is print out a million sucessfully deleted but I'm confused on why it does this.