Re: dealing with the headers in ascii file

From: ahmed lasheen <ahmed4kernel_at_nyahnyahspammersnyahnyah>
Date: Tue Feb 15 2011 - 03:04:20 MST

sorry for my late response , the code is working very good
thanks

On Sun, Feb 13, 2011 at 12:15 AM, Dennis Shea <shea@ucar.edu> wrote:

> The following should work:
>
> ;============================================
> diri = "./"
> fili = "cairo.txt"
> sdata = asciiread(diri+fili, -1, "string")
> nlines = dimsizes(sdata) ; Total number of lines in file
>
> ncols = 15
> nrows = 15 ; number of rows per iteration with numbers
> NROWS = nrows+1 ; includes header
> niter = nlines/NROWS ; number of iterations
> print("niter="+niter)
>
> data = new ( (/niter,nrows,ncols/), "float")
>
> kline = -1
> do ni=0,niter-1
> nr = -1
> do NR=0,NROWS-1
> kline = kline+1
> if (.not.(kline%NROWS).eq.0) then
> nr = nr+1
> data(ni,nr,:) = tofloat(str_split(sdata(kline)," "))
> end if
> end do
> end do
>
> wopt = True
> do ni=0,niter-1
> wopt@title = "write_matrix: iteration="+(ni+1)
> write_matrix(data(ni,:,:),ncols + "f9.4",wopt) ; Formatted output
> end do
> ;================================================
>
>

-- 
===============
Ahmed Lasheen
Junior researcher at Cairo Numerical Weather Prediction Center (CNWPC)
Egyptian Meteorological Authority(EMA)
Cairo,Egypt
===============

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Feb 15 03:05:08 2011

This archive was generated by hypermail 2.1.8 : Tue Feb 15 2011 - 09:43:19 MST