lundi 2 mars 2015

Genfromtxt error - Got n columns instead of m


Vote count:

1




I am trying to import data using numpy's genfromtxt with header names and non-homogeneous data types. Every time I run the program I get the error:



Traceback (most recent call last):
raise ValueError(errmsg)
ValueError: Some errors were detected !
Line #8 (got 6 columns instead of 1)
Line #9 (got 6 columns instead of 1)
Line #10 (got 6 columns instead of 1)
Line #11 (got 6 columns instead of 1)
Line #12 (got 6 columns instead of 1)


I have already gone through this question but it didn't solve my problem. It is a very simple problem, but I can't figure out what is wrong. The code and data is included:


Code



import numpy as np
data = np.genfromtxt('Data.dat', comments='#', delimiter='\t', names=True, dtype=None).transpose()
print data


Data



# -----
# -----
# -----
# -----
# -----
# -----
# -----
column_1 column_2 column_3 column 4 column_5 column_6
1 2 3 A 1 F
4 3 2 B 2 G
1 4 3 C 3 H
5 6 4 D 4 I


asked 56 secs ago







Genfromtxt error - Got n columns instead of m

Aucun commentaire:

Enregistrer un commentaire