Re: asciiread warning

From: Dave Allured - NOAA Affiliate <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Tue Nov 20 2012 - 13:52:12 MST

Sima,

Do your ascii files have fixed width columns? If so, then there is a
common problem that causes exactly this symptom. Some of the numbers
may be large enough that there are no spaces between adjacent columns.
 Asciiread can not read these files directly as individual numbers.

Instead, read each file as type string, then use str_get_cols to get
numbers from individual fixed width columns. See example asc3 on this
page, but you will have to allocate your own 2-D array, and add a loop
over columns:

http://www.ncl.ucar.edu/Applications/read_ascii.shtml#asc3

--Dave

On Tue, Nov 20, 2012 at 1:30 AM, sima sima <simasima_64@yahoo.com> wrote:
> Hi ncl-talk,
>
> I'm having problem with reading ascii files, I have 2000 files that every
> file has (1201*1201) array,
> I need to convert them in a binary format, my code is here:
>
> begin
>
> lst = systemfunc("ls ../Final/")
>
> n = dimsizes(lst)
>
> do i= 0, n-1
> a = asciiread(lst(i),(/1201,1201/),"float")
>
> setfileoption("bin","WriteByteOrder","BigEndian")
> cbinwrite(lst(i),a)
> end do
>
> end
>
> but when I run this code, I got a lot of warnings, ( probably for every
> ascii file) like follows:
>
> warning:asciiread: End of file reached and only (1030385) elements were read
> from the file, filling remaining elements with the default missing value for
> the requested type
> warning:asciiread: End of file reached and only (1030385) elements were read
> from the file, filling remaining elements with the default missing value for
> the requested type
> warning:asciiread: End of file reached and only (1030385) elements were read
> from the file, filling remaining elements with the default missing value for
> the requested type
> warning:asciiread: End of file reached and only (1030386) elements were read
> from the file, filling remaining elements with the default missing value for
> the requested type
> warning:asciiread: End of file reached and only (1030093) elements were read
> from the file, filling remaining elements with the default missing value for
> the requested type
> warning:asciiread: End of file reached and only (1030103) elements were read
> from the file, filling remaining elements with the default missing value for
> the requested type.
>
> could you please give me a solution?
>
> Thanks,
>
> Sima
>
>
>
> _______________________________________________
> 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 Tue Nov 20 13:52:50 2012

This archive was generated by hypermail 2.1.8 : Wed Nov 21 2012 - 11:16:05 MST