python - Reading Single Line CSV using numpy.genfromtxt -
I am using the following script to use a file from numerical numpy using standard input. Works in a manner that has more than 1 line but fails to work for this file:
1,2,2,2,2,1,1,1, 1 I am running it like this
$ cat input-file.txt | ./test.py The output is as follows:
(9,) [1. 2. 2. 2. 2. 2. 1. 1. 1] should have a shape (9). Does anyone know the way to fix it?
Force it in a 2-dimensional array:
Data = Np.genfromtxt (sys.stdin, delimiter = ",") if len (data.shape) == 1: data = np.array ([data])
Comments
Post a Comment