numpy loadtxt - ValueError: setting an array element with a sequence.

Have you tried the numpy.fromfile function? This usually worked great for my files that had the same format than yours.
++
Peter
---------------------- PhD Student at the Molecular Modeling and Bioinformatics Group Dep. Physical Chemistry Faculty of Pharmacy University of Barcelona

Peter Schmidtke wrote:
Have you tried the numpy.fromfile function?
good point -- fromfile() can be much faster for the simple cases it can handle.
not all lines ave the same lenght (not the same number of values).
What would be the best way to load this?
That depends on what the data mean. Is it a 2-d array with missing values? If so, how do you know which are missing? Are there the same number of tabs in each row? If do than loadtxt should be able to handle it.
You may be best off looping through the file:
for line in file: a = numpy.fromstring(line, sep='\t', dtype=np.float)
and do what makes sense with each line.
-Chris
participants (2)
-
Christopher Barker
-
Peter Schmidtke