You might be able to read the whole file, and use variables to
split it up into its different parts, perhaps saving them to
NetCDF or other separate files for simpler future use.
FILE/FORM=DELIM lets you tell Ferret to read the missing
fields in the header rows as missing data for the second and third
variables. This isn't simple or pretty, but it may get you started.
yes? file/var=v1,v2,v3/form=delim/type=numeric/delim=" " twosets.dat
yes? list v1,v2,v3
DATA SET: ./twosets.dat
X: 0.5 to 9.5
Column 1: V1
Column 2: V2
Column 3: V3
V1 V2 V3
1 / 1: 3.00 ....
....
2 / 2: 1.00 2.00
3.00
3 / 3: 4.00 5.00
6.00
4 / 4: 7.00 8.00
9.00
5 / 5: 4.00 ....
....
6 / 6: 1.00 2.00
3.00
7 / 7: 4.00 5.00
6.00
8 / 8: 7.00 8.00
9.00
9 / 9: 10.00 11.00 12.00
yes? let head1 = 1
yes? let start1 = head1 + 1
yes? let end1 = start1 + v1[i=`head1`] - 1
yes? list/nohead start1, end1
I / *: 2.000 4.000
yes? let v1_1 = v1[i=`start1`:`end1`]
yes? let v2_1 = v2[i=`start1`:`end1`]
yes? let v3_1 = v3[i=`start1`:`end1`]
yes? list v1_1, v2_1, v3_1
yes? list v1_1, v2_1, v3_1
DATA SET: ./twosets.dat
X: 1.5 to 4.5
Column 1: V1_1 is V1[I=2:4]
Column 2: V2_1 is V2[I=2:4]
Column 3: V3_1 is V3[I=2:4]
V1_1
V2_1 V3_1
2 / 2: 1.000 2.000 3.000
3 / 3: 4.000 5.000 6.000
4 / 4: 7.000 8.000 9.000
yes? let head2 = end1 + 1 ! and so forth...
Steve Knox wrote:
Hello,
I've scanned the archives but am unable to find a solution to reading
multiple datasets from a single file.I have an ascii file with separate datasets separated by a header line.
There are 3 variables/row and the header indicates the number of rows.
In the following example, there are 2 datasets, the first has 3 columns by
3 rows; the second has 3 columns by 4 rows.
Is it possible to read the number of rows from the header and then read
only that many rows, then read the next header and read the rows for that
dataset, etc?3 (This header indicates 3 rows)
1 2 3
4 5 6
7 8 9
4 (This header indicates 4 rows)
1 2 3
4 5 6
7 8 9
10 11 12Thanks for any help.
Steve
--
Ansley Manke Pacific Marine Environmental Laboratory Seattle
WA (206)526-6246