; Some lines in the text files have missing last colums. ; By default, NCL issues warning messages. ; Unfortunately, there are many lines in each file with missing last valies (fields) ; ;---Avoid printing Warning messages. They can be a nuisance. err = NhlGetErrorObjectId() setvalues err "errLevel" : "Fatal" ; only report Fatal errors end setvalues ; General input information fname1 = "./vento_direzione_201911.TXT" lines1 = asciiread(fname1,-1,"string") printVarSummary(lines1) print("---------------------") nline1 = dimsizes(lines1) print("nline1="+nline1) print("---------------------") ; effect of different delimeters delim_a = ";" nfld_a = str_fields_count(lines1, delim_a) delim_b = ";/" nfld_b = str_fields_count(lines1, delim_b) delim_c = ";/:" nfld_c = str_fields_count(lines1, delim_c) print("nfld_a[;]="+nfld_a+" nfld_b[;/]="+nfld_b+" nfld_c[;/:]="+nfld_c) print("---------------------") print("---------------------") print("---------------------") ; extract the date (MM/DD/YY) and time (HH/MN) date = str_get_field(lines1, 1, delim_a) ; also delim_b and delim_c work fine time = str_get_field(lines1, 2, delim_a) print(date+" "+time) print("---------------------") print("---------------------") print("---------------------") ; use the poster's original delim delim = delim_a ; this is what was used dpiatt = stringtoint(str_get_field(lines1, 3, delim)) dmalpor = stringtoint(str_get_field(lines1, 6, delim)) dchipor = stringtoint(str_get_field(lines1, 7, delim)) dsang = stringtoint(str_get_field(lines1, 9, delim)) field_10= stringtoint(str_get_field(lines1, 10, delim)) print(dpiatt+" "+dmalpor+" "+dmalpor+" "+dsang+" "+field_10) print("---------------------") print("---------------------") print("---------------------") ; The 11-th field is NOT present in some lines ; Example: ; 12/11/19;00:00;39;42;53;60;35;47;33;272;359 <=== 359 is the 11th field value ; 12/11/19;00:05;37;40;51;60;32;48;31;111; <=== last field value (#11) is missing ; 12/11/19;00:10;35;43;48;64;36;48;30;356;23 <=== 23 is the 11th field value dmeab = stringtoint(str_get_field(lines1, 11, delim)) ; will return default integer _FillValue dmeab@_FillValue = -999 ; change the default to -999 print(dmeab(0:3))