0
I’m trying to run the code:
import csv
listaG = []
arquivoSaida = 'teste.csv'
with open('Arquivos_avanco.txt', newline='') as csvfile:
spamreader = csv.reader(csvfile, delimiter='-', quotechar='|')
for row in spamreader:
listaG.append([','.join(row)])
#print (','.join(row))
with open(arquivoSaida, 'wb') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',', quoting=csv.QUOTE_MINIMAL)
spamwriter.writerow(['Marca', 'Modelo', 'Ano'])
for i in listaG:
spamwriter.writerow(i)
Error returned:
Traceback (Most recent call last): File "E: Johann Herbert Desktop python_test.py course", line 50, in spamwriter.writerow(['Brand', 'Model', 'Year'])
Typeerror: a bytes-like Object is required, not 'str'
I’m a beginner in language
And you do not need to open a file, read all the content in a list to then save it in another file; you can write as you read, in the same loop of repetition
– Woss