[Numpy-discussion] Scientific data - Reading files
Chris Barker
Chris.Barker at noaa.gov
Mon Aug 12 12:16:08 EDT 2002
Nils Wagner wrote:
> Each file (E1431A*.DAT) contains
> one column with real numbers. The contents of the i-th file should be
> stored in the i-th row of a data matrix A.
Are the files binary or ASCI ?
if ASCI, look in Scipy, there are a couple of modules for this kind of
thing, I doubt any of them are set up for multiple files, so you'll have
to loop through the file list.
If binary, you can do something like:
while row < NumRows:
file = open(filename,'rb')
A[row,:] = fromstring(file.read(),Float) # make sure you get the
typecode right!
file.close()
row += 1
WARNING: not the least bit tested.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (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