Hello, I have the following code:
import csv
def carregar_acessos():
X = []
Y = []
arquivo = open('acesso_pagina.csv', 'rb')
leitor = csv.reader(arquivo)
next(leitor)
for home,como_funciona,contato,comprou in leitor:
dado = [int(home),int(como_funciona),int(contato)]
X.append(dado)
Y.append([int(comprou)])
It attempts to retrieve information from a CSV file containing several ZEROS and UNS. And I have another file that shows this in the terminal:
from dados import carregar_acessos
X,Y = carregar_acessos()
print(X)
print(Y)
But when I run the code the following error appears:
Traceback (most recent call last):
File "classifica_acesso.py", line 3, in <module>
X,Y = carregar_acessos()
File "/Users/josecarlosferreira/Desktop/machine-learning/dados.py", line 10, in carregar_acessos
next(leitor)
_csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)
Well, I saw some answers in Stackoverflow in English, but even trying the solutions proposed there, the code did not work and still kept the same error.
CSV is created this way:
home,como_funciona,contato,comprou
1,1,0,0
1,1,0,0
1,1,0,0
1,1,0,0
1,1,0,0
1,0,1,1
1,1,0,0
1,0,1,1
1,1,0,0
1,0,1,1
And it goes on for 200 more lines. They each indicate a SIM (1) and NO (0) information. Could someone help me?