I am trying to read a .csv file using Numpy. The .csv file has this format:
U118,V078,3 U106,V091,2 U042,V057,5
I used numpy.genfromtxt function defining the data types in the argument:
data = np.genfromtxt('DATASET.csv', delimiter=",",names=['usuario','videojuego','puntuacion'],
dtype='str,str,int')
But what I am actually getting is only the int (3rd column) column:
> [('', '', 3) ('', '', 2) ('', '', 5) ('', '', 0) ('', '', 3) ('', '',
> 5)
Does someone know what I am missing?
np.genfromtxtexpects a list ofdtypesto be assigned to attributes. So usedtype = ['str', 'int', 'int']dtypeyou'll see it'sU0', string type with space for 0 characters. Some places it's ok to usestr` as the dtype, but for others, such as this, you need to specify the length.