3
Hello, I am taking a course of Machine Learning/Classification and well it uses a CSV file in which one should ignore the first line of the file. So I made the following code:
import csv
def carregar_acessos():
X = []
Y = []
arquivo = open('acesso_pagina.csv', 'rb')
leitor = csv.reader(arquivo)
leitor.next()
for home,como_funciona,contato,comprou in leitor:
dado = [int(home),int(como_funciona),int(contato)]
X.append(dado)
Y.append([int(comprou)])
But when the executor informs that the "reader" has no NEXT attribute. Someone could help me?
Return from the Terminal:
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 11, in carregar_acessos
leitor.next()
AttributeError: '_csv.reader' object has no attribute 'next'
According to what is shown in the class the code is correct and should work. But I tried to look into the change in Next, and I tested other codes I found.
Note: The first line of the CSV file is a Text and all the others are integer numbers.
I’m sorry, but I don’t think you quite understand what I mean. If my code is not implementing next() it means I need to implement next ? But where would this be implemented? Sorry, I’m discovering the world of programming and there are many things that still leave me a little confused.
– JKFher