[ncl-talk] readAsciiTable to handle blanks in data
xiaoming Hu
yuanfangcan at hotmail.com
Tue Jul 27 17:34:03 MDT 2021
need to read tables with blank spaces like the one below.
Is there any easier way to read this table without manually inserting some dummy values in the blank space?
[cid:430a5345-b411-4159-b0a5-f2f78a07ecf2]
Thanks a lot!
Xiaoming Hu
________________________________
From: ncl-talk <ncl-talk-bounces at ucar.edu> on behalf of xiaoming Hu <yuanfangcan at hotmail.com>
Sent: Tuesday, April 9, 2019 4:52 PM
To: Dennis Shea <shea at ucar.edu>
Cc: Ncl-talk <ncl-talk at ucar.edu>; Xiaoming Hu <xhu at ou.edu>
Subject: Re: [ncl-talk] readAsciiTable to handle ***** in data
Dennis
Thank you so much! I agree "Likely, a fortran code with f4.1 was used but should have been f5.1".
You code is really helpful:
ndat = numAsciiRow(pthtxt)
ncol = numAsciiCol(pthtxt)
print("ndat="+ndat+"; ncol="+ncol)
dstr = asciiread(pthtxt, -1, "string")
dstr := str_sub_str(dstr,"*****","999.9") ; change
print(dstr)
delim = " "
id = str_get_field(dstr, 1, delim) ; toint(str_get_field(dstr, 1, delim) )
col27 = tofloat( str_get_field(dstr,27, delim) )
col28 = tofloat( str_get_field(dstr,28, delim) )
col27 = where(col27.eq.999.9, 99999.0, 88888.0) ; whatever you wany
i9999 = ind(.not.(col28.eq.999.9)) ; rows/line where a 999.9 does not appear
print(id+" "+col27+" "+col28)
Xiaoming
________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210727/d037735f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 106547 bytes
Desc: image.png
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210727/d037735f/attachment.png>
More information about the ncl-talk
mailing list