Re: Asciiread

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Fri Aug 03 2012 - 07:31:05 MDT

Ivanna,

Try the script below.

Wei

huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924

----------------
 str = asciiread("data.txt",-1,"string")
 print(str)

 strs = str_split_csv(str, " ", 0)
 print(strs)

 dat = toint(strs)
 print(dat)

 dat@_FillValue = -999
 print(dat)

On Aug 3, 2012, at 3:26 AM, Ivanna Mo wrote:

> Hi,
> I want to read a data file (all numeric) with and non-uniform number of column:
>
> 1 2 3
> 4 5
> 7 8 9
> ------------------------------------
> and when I use asciiread:
>
> f= asciiread("data",-1,"float")
> print(f)
>
> the output is:
>
> Variable: f
> Type: float
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 1
> -----------------------------------------
>
> a=asciiread("data",(/3,3/),"float")
> print(a)
>
> the output is:
> Variable: a
> Type: float
> Total Size: 36 bytes
> 9 values
> Number of Dimensions: 2
> Dimensions and sizes: [3] x [3]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : -999
> (0,0) 1
> (0,1) -999
> (0,2) -999
> (1,0) -999
> (1,1) -999
> (1,2) -999
> (2,0) -999
> (2,1) -999
> (2,2) -999
> ---------------------------------------------
> But what I want is an array like this:
> (0,0) 1
> (0,1) 2
> (0,2) 3
> (1,0) 4
> (1,1) 5
> (1,2) -999
> (2,0) 7
> (2,1) 8
> (2,2) 9
>
> can anyone help?
>
> Thank you very much!
> Ivanna
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Aug 3 07:31:21 2012

This archive was generated by hypermail 2.1.8 : Fri Aug 03 2012 - 14:39:58 MDT