ASCII Table File Format

I've found it useful to define a standard format for variable-length arrays stored in ASCII files, so they are easily readable by a variety of programs (C, IDL, SM, etc.). For an array of ndim dimensions, each of size size_i, this form is:

[ndim] [size_{0}] ... [size_{ndim-1}]
[entry_0]
[entry_1]
...
[entry_n]
...
[entry_{size_0*size_1*..*size_{ndim-1}-1]
where the table element [i][j][k] (for ndim==3 and C-indexing) would be the entry element n, where n=i*size_2*size1+j*size2+k. This format allows programs like IDL and C to set the input arrays to the appropriate size before inputting, while simultaneously giving a fixed number of lines SM can ignore (only the first) when inputting the list.

For example, the IDL array [[1,2,3],[4,5,6],[7,8,9],[10,11,12]] would be stored as:

2 4 3 
1.00000000
2.00000000
3.00000000
4.00000000
5.00000000
6.00000000
7.00000000
8.00000000
9.00000000
10.00000000
11.00000000
12.00000000
That is, there are two dimensions, the outer dimension having 4 elements, and the inner dimension having 3; then the line-separated list of twelve values.

In C and IDL, I have implemented the routines k_load_ascii_table and k_write_ascii_table to read and to create these files. These routines only deal with tables of type "float."


Snail Mail: Michael Blanton; Email: mb144@nyu.edu