I’ve got csv file that stores some info (see screenshot).
with open('items.csv', 'w') as csvfile:
csvreader = csv.reader(csvfile)
csvwriter = csv.writer(csvfile)
for i in range (len(select.values)):
for row in csvreader:
if row[0] == select.values[i]:
csvwriter.writerow([row[0], interaction.user.id])
select.values
is a list of values, that were chosen by user (for example ['25', '37']
). I want to change row[1]
of line where ‘row[0]’ is 25 to interaction.user.id
(which is an int
object) and nothing else. But my code clears .csv
file and it leads to further mistakes. How do i fix it?