[Numpy-discussion] Help using numPy to create a very large multi dimensional array

Christopher Barker Chris.Barker at noaa.gov
Wed Apr 18 12:11:32 EDT 2007


Bruno Santos wrote:
> Finally I was able to read the data, by using the command you sair with 
> some small changes:
> matrix = numpy.array([[float(x) for x in line.split()[1:]] for line in 
> vecfile])

it doesn't sound like you're concerned about the speed of reading the 
files, but you can still use fromfile() or maybe fromstring() to do 
this. You just need to read past the text part first, then process it.

using fromstring:

matrix = numpy.vstack([numpy.fromstring(line.split(" ", 1)[1], sep=" ") 
for line in vecfile])

or something like that.

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list