Receiving Nan (not a number) while reading a .CSV file with numpy

1

Using python 3.6.5

import numpy as np

valores = np.genfromtxt("arquivo.csv",delimiter = ";",skip_header = 1)
print(valores)

.csv file:

Valores1,Valores2,Valores3
10,20,30
40,50,60
70,80,90
34,54,23

Output:

array([nan, nan, nan, nan])

What's happening?

    
asked by anonymous 30.04.2018 / 01:20

1 answer

2

As already indicated in the comments, it is only the parameter of the delimiter that is wrong. When changing from ";" to "," the code works:

import numpy as np
valores = np.genfromtxt("arquivo.csv", delimiter=",", skip_header=1)
print(valores)

# saída:
[[10. 20. 30.]
 [40. 50. 60.]
 [70. 80. 90.]
 [34. 54. 23.]]
    
03.05.2018 / 02:24