Re: reading ascii data with unequal number of columns

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri, 15 Sep 2006 08:19:00 -0600 (MDT)

> I have an ASCII file of known number of lines, however the number of elements on
> each line is unknown. Is there any function in NCL that can read this data, so
> that, if the resulting variable is A, A(0) is the first line, A(1) is the
> second line, and so on?
>
> ASCII file is like this:
>
> 0.1 0.2 0.4 0.1
> 2.3
> 2.7 2.0
> 1.1
>
> I can fill the incomplete lines up to the number of elements of longest line and
> then read the data into a 2-d array with missing values.. but I wondered if I
> really have to do this..
> ----------------------------------------------------------------
I am not sure exactly what you are asking.

If you are asking that the above be automatically be read into
a 4x4 array, the answer is no.

More generally, I think you are asking that an ascii file with arbitrary
column [C] and row [R] elements and an irregular structure automatically be
read into a RxC array. Sorry, no.

[1]
ncl 1> x = asciiread("ozan.asc", -1, "float")
ncl 2> print(x)

Variable: x
Type: float
Total Size: 32 bytes
             8 values
Number of Dimensions: 1
Dimensions and sizes: [8]
Coordinates:
(0) 0.1
(1) 0.2
(2) 0.4
(3) 0.1
(4) 2.3
(5) 2.7
(6) 2
(7) 1.1

good luck
D
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Sep 15 2006 - 08:19:00 MDT

This archive was generated by hypermail 2.2.0 : Fri Sep 15 2006 - 17:13:34 MDT