[ncl-talk] readAsciiTable to handle ***** in data
xiaoming Hu
yuanfangcan at hotmail.com
Tue Apr 9 15:52:35 MDT 2019
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
________________________________
From: Dennis Shea <shea at ucar.edu>
Sent: Tuesday, April 9, 2019 4:41 PM
To: xiaoming Hu
Cc: Ncl-talk; Xiaoming Hu
Subject: Re: [ncl-talk] readAsciiTable to handle ***** in data
Likely, a fortran code with f4.1 was used but should have been f5.1
===
%> ncl XiaomingHu.ncl
===0) ndat=7; ncol=32
Variable: dstr
Type: string
Total Size: 56 bytes
7 values
Number of Dimensions: 1
Dimensions and sizes: [7]
Coordinates:
(0) 72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 55 7.29 14 94 7000 1.0 5 -70.2 -98.3 18481 18638 12.5 247
(1) 72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 55 56.21 28 94 6689 1.0 5 -72.3 -99.8 18750 18907 15.5 228
(2) 72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 56 16.21 21 94 6570 1.0 5 -72.9 999.9 18855 19014 17.2 229
(3) 72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 56 54.21 28 94 6360 1.0 5 -73.1 999.9 19046 19210 19.1 243
(4) 72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 58 24.21 28 94 5861 1.0 5 -73.0 999.9 19525 19694 13.5 290
(5) 72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 58 48.21 21 94 5744 1.0 5 -72.9 999.9 19643 19816 14.3 291
(6) 72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 59 29.21 28 94 5551 1.0 5 -69.3 -97.6 19846 20025 11.7 290
(0) 72249 88888 -98.3
(1) 72249 88888 -99.8
(2) 72249 88888 999.9
(3) 72249 88888 999.9
(4) 72249 88888 999.9
(5) 72249 88888 999.9
(6) 72249 88888 -97.6
(0) ---
Variable: dstr (subsection)
Type: string
Total Size: 24 bytes
3 values
Number of Dimensions: 1
Dimensions and sizes: [3]
Coordinates:
(0) 72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 55 7.29 14 94 7000 1.0 5 -70.2 -98.3 18481 18638 12.5 247
(1) 72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 55 56.21 28 94 6689 1.0 5 -72.3 -99.8 18750 18907 15.5 228
(2) 72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 59 29.21 28 94 5551 1.0 5 -69.3 -97.6 19846 20025 11.7 290
(0) ---
On Tue, Apr 9, 2019 at 10:18 AM xiaoming Hu <yuanfangcan at hotmail.com<mailto:yuanfangcan at hotmail.com>> wrote:
I need to read a lot of table data. but some of them contains **** (but the number and location of **** in the file are uncertain), see one of the examples below.
What is the best way to handle the **** in these files other than manually removing them? I am currently using readAsciiTable to read.
Thanks a lot!
Xiaoming
72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 55 7.29 14 94 7000 1.0 5 -70.2 -98.3 18481 18638 12.5 247
72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 55 56.21 28 94 6689 1.0 5 -72.3 -99.8 18750 18907 15.5 228
72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 56 16.21 21 94 6570 1.0 5 -72.9 ***** 18855 19014 17.2 229
72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 56 54.21 28 94 6360 1.0 5 -73.1 ***** 19046 19210 19.1 243
72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 58 24.21 28 94 5861 1.0 5 -73.0 ***** 19525 19694 13.5 290
72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 58 48.21 21 94 5744 1.0 5 -72.9 ***** 19643 19816 14.3 291
72249 03990 87 3 2008 3 31 11 51 55.21 32.83500 -97.29806 199 195 6 2008 3 31 12 59 29.21 28 94 5551 1.0 5 -69.3 -97.6 19846 20025 11.7 290
_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu<mailto: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/20190409/8a8076e7/attachment.html>
More information about the ncl-talk
mailing list