[ncl-talk] read ascii file line by line
Kyle Griffin
ksgriffin2 at wisc.edu
Thu Nov 19 07:58:04 MST 2015
A quick NCL search for 'read ascii' reveals a function that can do what you
want.
https://www.ncl.ucar.edu/Document/Functions/Built-in/asciiread.shtml
I use this function for exactly this purpose, and combine with
str_get_field as necessary to parse out values from columns.
Be sure to read the part to understand the dimension setting to ensure the
file is read by individual lines.
Kyle
----------------------------------------
Kyle S. Griffin
Department of Atmospheric and Oceanic Sciences
University of Wisconsin - Madison
Room 1407
1225 W Dayton St, Madison, WI 53706
Email: ksgriffin2 at wisc.edu
On Thu, Nov 19, 2015 at 6:09 AM, Marston Johnston <marston.johnston at gu.se>
wrote:
> Hi,
>
> It is possible to read an ascii file line by line with NCL?
> I have a file with header information but some rows have
> fewer columns than others. The causes NCL to misread the file since it
> doesn’t pad the missing columns with 0s.
> Here’s and example of the file:
>
> 90 000001 017
> 13 000001 001 1989010118 1989 01 01 18 -22.50 76.50 97321.5 -999.999
> -999.999
> 13 000001 002 1989010200 1989 01 02 00 -15.00 78.00 96884.5 -999.999
> -999.999
> 13 000001 003 1989010206 1989 01 02 06 -9.00 78.00 96481.6 -999.999
> -999.999
> 13 000001 004 1989010212 1989 01 02 12 9.00 78.00 95855.4 -999.999
> -999.999
> 13 000001 005 1989010218 1989 01 02 18 10.50 79.50 95618.0 -999.999
> -999.999
> 13 000001 006 1989010300 1989 01 03 00 10.50 79.50 95862.3 -999.999
> -999.999
> 13 000001 007 1989010306 1989 01 03 06 24.00 79.50 96049.5 -999.999
> -999.999
> 13 000001 008 1989010312 1989 01 03 12 25.50 79.50 96741.5 -999.999
> -999.999
> 13 000001 009 1989010318 1989 01 03 18 30.00 76.50 97431.5 -999.999
> -999.999
> 13 000001 010 1989010400 1989 01 04 00 37.50 75.00 98005.7 -999.999
> -999.999
> 13 000001 011 1989010406 1989 01 04 06 51.00 78.00 98294.2 -999.999
> -999.999
> 13 000001 012 1989010412 1989 01 04 12 52.50 78.00 98539.0 -999.999
> -999.999
> 13 000001 013 1989010418 1989 01 04 18 54.00 78.00 98684.7 -999.999
> -999.999
> 13 000001 014 1989010500 1989 01 05 00 52.50 78.00 98801.7 -999.999
> -999.999
> 13 000001 015 1989010506 1989 01 05 06 49.50 78.00 98859.1 -999.999
> -999.999
> 13 000001 016 1989010512 1989 01 05 12 49.50 78.00 99021.5 -999.999
> -999.999
> 13 000001 017 1989010518 1989 01 05 18 60.00 76.50 98882.8 -999.999
> -999.999
> 90 000002 020
> 13 000002 001 1989010100 1989 01 01 00 49.50 51.00 98664.4 -999.999
> -999.999
> 13 000002 002 1989010106 1989 01 01 06 57.75 53.25 98746.9 -999.999
> -999.999
>
>
> Any help is appreciated,
> /Marston
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151119/321ff182/attachment.html
More information about the ncl-talk
mailing list