[Numpy-discussion] avoid a line...
Christopher Barker
Chris.Barker@noaa....
Thu Mar 17 10:32:37 CDT 2011
On 3/17/11 12:46 AM, eat wrote:
> I am try to read a file of the following format, I want to avoid
> the first line and read the remaining as 'float' .
> Please help me...
>
>
> Rain Wind Temp Pr Sal
> 0.1 1.1 0.02 0.2 0.2
> 0.5 0. 0. 0.4 0.8
> 0.5 5.5 1.5 0.5 1.5
It's not as robust, but if performance matters, fromfile() should be faster:
f.readline() # to skip the first line
arr = np.fromfile(f, sep=' ', dtype=np.float64).reshape((-1, 5))
(untested)
-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@noaa.gov
More information about the NumPy-Discussion
mailing list