Re: ncl problem about asciiread

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Thu Nov 10 2011 - 11:18:58 MST

Hi Ziquang,
Why is this strange? NCL counts each instance of a newline character as a line. The first file counts as 2 lines and the second file counts as 3 lines with the last line having 0 characters (using the strlen function). If you put 2 newlines in a row in the middle of the file you could have additional 0 character lines. The Unix tool 'wc' agrees with NCL:

$ wc file1.txt
       2 6 34 file1.txt
$ wc file2.txt
       3 6 35 file2.txt

(The first number for wc is the number of lines it thinks is in the file.)
By the way, you never say what 'n' is, so I don't know for sure what you are really expecting.
 -dave

On Nov 8, 2011, at 9:49 PM, JiangZiqiang wrote:

> Hello,
>
> when using asciiread to read txt file, there is a interesting phenomenon.
> if there is "line break" delimeter at the end of file , lines of data to read in is n,
> but if no "line break" delimeter, it is n-1. I think it is a strange thing.
>
> print( dimsizes( asciiread("???.txt",-1,"string") ) )
> file1:
> "
> .026, .016, -999
> .026, .016, -999
> "
> file2:
> "
> .026, .016, -999
> .026, .016, -999
>
> "
> (there is no quote " in the file)
>
> Thank you for help
>
> Ziqiang
> _______________________________________________
> 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 Thu Nov 10 11:19:11 2011

This archive was generated by hypermail 2.1.8 : Mon Nov 14 2011 - 10:41:55 MST