0
What I would like to do is that when the user typed the name of a person who was inside the file. csv, his line and the lines of movies he evaluated were erased (I used an identifier for this), the code is this:
import csv
with open("arquivo.csv", "r") as arq:
linhas = csv.reader(arq, delimiter=";")
critico = input("Digite o nome do crítico que você deseja deletar..: ").capitalize()
for linha in linhas:
tipo, identificador, nome, nota = linha
if tipo == "C":
if critico in linha:
ident = linha[1]
print(linha)
if tipo == "F" and identificador == ident:
print(linha)
and I’m using this data saved in . csv to read:
C;1;Kenneth;[email protected]
F;1;Matrix;5.0
F;1;Mad Max;4.5
C;2;Josue;[email protected]
F;2;Miss Sunshine;4.2
C;3;Maria;[email protected]
F;3;Amelie Poulain;3.0
F;3;Drive;2.0
What to do to delete a critic’s lines?
Question: if you search for the name of the critic, it would not be enough for you to compare
critico == nome
instead of doingcritico in linha
? And when located the critical, is stored inident
the value ofidentificador
and all lines with this identifier shall be removed?– Woss
Yes, seeing here you are correct, is that I knew about this method of putting variables for each column now. When the critic is located all lines with this identifier should be removed, then yes.
– Kenneth Anderson