[SciPy-user] reading data into a RecordArray
Mon Dec 24 00:02:48 CST 2007
On Dec 23, 2007 5:42 PM, Andrew Charles <firstname.lastname@example.org> wrote:
> I'm relatively new to python, and new to this list. Hello everyone - I
> really like what you're doing with scipy.
> My question relates to code I'm writing to convert my ASCII data to netCDF.
> I'm trying to:
> 1. Read in the data file
> 2. Read in a file containing the column headers
> 3. Merge the two into a record array
> I've read the overview (http://www.scipy.org/RecordArrays ), and gone back
> over the introductory material on lists and tuples, but I've stumped myself.
> The code
> from scipy import *
> colfile = open("my_column_spec.txt")
> cols = colfile.readlines()
> for col in cols:
> columns = columns + [(col,'f4')]
Try at this point in the code:
columns = tuple(columns)
> ifile = open("my_ascii_data.txt")
> data = io.array_import.read_array(ifile)
> data = array(data,columns)
> fails on the last line with the error "expected a readable buffer object".
> In case it's relevant, dt.shape is (1984,22) and len(cols) is 22. Any
> pointers as to what I'm doing wrong?
And let us know if it helps.
More information about the SciPy-user