<div dir="ltr"><div dir="ltr">Hello:<div><br></div><div>Just to add a bit:</div><div><br></div><div>This page confirms what Mary wrote:</div><div><br></div><div><a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/str_get_field.shtml">https://www.ncl.ucar.edu/Document/Functions/Built-in/str_get_field.shtml</a><br></div><div><br></div><div><span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px">"If one or more delimiters appear side-by-side in a string, then they are treated as if they were just one delimiter. See the examples below for a way to handle consecutive delimiters."</span><br></div><div><span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px"><br></span></div><div><span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px">and offers a way around this (although I am not sure why one would need to do this if you have str_get_csv</span></div><div><span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px"><br></span></div><div><span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px">To make sure that the empty fields between the consecutive delimiters get treated as real values, use </span><a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/str_sub_str.shtml" style="margin:0px;padding:0px;text-decoration-line:none;color:rgb(133,45,133);font-family:verdana,sans-serif;font-size:13.3333px"><strong style="margin:0px;padding:0px">str_sub_str</strong></a><span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px"> to insert a number between these delimiters.</span><span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px"><br></span></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Aug 31, 2018 at 6:32 PM Mary Haley <<a href="mailto:haley@ucar.edu">haley@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Barry,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">This is not a bug, but I do think it's an unfortunate reality of the way "str_get_field" works.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">What you want to use is str_split_csv instead. You read your lines as an arrays of strings using asciiread (as you're already doing), and then use str_split_csv which will split those lines into a 2D array based on a delimiter.  It will correctly treat fields with two commas right next to each other as missing values. You can then parse out the columns you need, and use tofloat or toint to convert them from strings to floats or ints. </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I've attached a sample script based on your data file.  </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Here's a snippet:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">  asc_file = "weather_it_is_telav_20180831_052522.csv"</font></div><div class="gmail_default"><font face="monospace, monospace">  delim = ","</font></div><div class="gmail_default"><font face="monospace, monospace">  lines = asciiread(asc_file,-1,"string")</font></div><div class="gmail_default"><font face="monospace, monospace">  csv_lines = str_split_csv(lines(1:),delim,0)</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace">  Station                         = csv_lines(:,0)    ; read column 1                                                         </font></div><div class="gmail_default"><font face="monospace, monospace">  ObservationTimeUtc              = csv_lines(:,1)    ; read column 2                                                         </font></div><div class="gmail_default"><font face="monospace, monospace">  DewPointC                       = tofloat(csv_lines(:,2))    ; etc</font></div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Here's the full output:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><div class="gmail_default"><font face="monospace, monospace">Station                         = TELAV,TELAV</font></div><div class="gmail_default"><font face="monospace, monospace">ObservationTimeUtc              = 8/31/2018 5:05:12 AM,8/31/2018 5:00:06 AM</font></div><div class="gmail_default"><font face="monospace, monospace">DewPointC                       = 22.0824,22.2439</font></div><div class="gmail_default"><font face="monospace, monospace">HeatIndexC                      = 29.8813,29.959</font></div><div class="gmail_default"><font face="monospace, monospace">Humidity                        = 72.4898,73.2047</font></div><div class="gmail_default"><font face="monospace, monospace">PressureSeaLevelMBar            = 1011.68,1011.64</font></div><div class="gmail_default"><font face="monospace, monospace">PressureSeaLevelMBarRatePerHour = 0.230187,0.21248</font></div><div class="gmail_default"><font face="monospace, monospace">RainMillimetersDaily            = 0,0</font></div><div class="gmail_default"><font face="monospace, monospace">RainMillimetersRatePerHour      = 0,0</font></div><div class="gmail_default"><font face="monospace, monospace">TemperatureC                    = 27.4375,27.4375</font></div><div class="gmail_default"><font face="monospace, monospace">VisibilityKilometers            = 9.96921e+36,9.96921e+36</font></div><div class="gmail_default"><font face="monospace, monospace">WindChillC                      = 27.4375,27.4375</font></div><div class="gmail_default"><font face="monospace, monospace">WindSpeedKph                    = 3.52784,3.52784</font></div><div class="gmail_default"><font face="monospace, monospace">WindDirectionDegrees            = 0,304</font></div><div class="gmail_default"><font face="monospace, monospace">WindSpeedKphAvg                 = 4.58619,2.82227</font></div><div class="gmail_default"><font face="monospace, monospace">WindDirectionDegreesAvg         = 339,300</font></div><div class="gmail_default"><font face="monospace, monospace">WindGustKphHourly               = 9.87795,9.52517</font></div><div class="gmail_default"><font face="monospace, monospace">WindGustTimeUtcHourly           = missing,missing</font></div><div class="gmail_default"><font face="monospace, monospace">WindGustKphDaily                = 15.8753,15.8753</font></div><div class="gmail_default"><font face="monospace, monospace">WindGustTimeUtcDaily            = missing,missing</font></div><div class="gmail_default"><font face="monospace, monospace">WetBulbTemperatureC             = 23.6,23.7</font></div><div class="gmail_default"><font face="monospace, monospace">FeelsLikeTemperatureC           = 29.8813,29.959</font></div><div class="gmail_default"><font face="monospace, monospace">RainRateMaxMmPerHour            = 0,0</font></div><div class="gmail_default"><font face="monospace, monospace">TemperatureHighC                = 27.4656,27.4375</font></div><div class="gmail_default"><font face="monospace, monospace">TemperatureHighUtc              = 8/31/2018 5:01:00 AM,8/31/2018 5:00:00 AM</font></div><div class="gmail_default"><font face="monospace, monospace">TemperatureLowC                 = 26.4351,26.4351</font></div><div class="gmail_default"><font face="monospace, monospace">TemperatureLowUtc               = 8/31/2018 1:57:00 AM,8/31/2018 1:57:00 AM</font></div><div class="gmail_default"><br></div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 31, 2018 at 5:27 AM, Barry Lynn <span dir="ltr"><<a href="mailto:barry.h.lynn@gmail.com" target="_blank">barry.h.lynn@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Please run this program in the following manner:</div><div><br></div><div><p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures">ncl ./parse_tau_obs.ncl year1=18 month1=08 day1=31</span></p><p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br></span></p><p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures">What you'll find is that the program skips over the double comma. The data that missing between the commas is the "Visibility." But, instead of noting visibility as missing it just moves on to the next variable, writing the next variable (WindChill) to Visibility.</span></p></div><div>





<p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures">0)<span class="m_644375482325041305m_-7593936103680568924gmail-Apple-tab-span" style="white-space:pre-wrap">   </span>TemperatureC = "TemperatureC"</span></p>
<p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures">(1)<span class="m_644375482325041305m_-7593936103680568924gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>TemperatureC = 27.4374727668845</span></p>
<p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures">(2)<span class="m_644375482325041305m_-7593936103680568924gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>TemperatureC = 27.4374727668845</span></p>
<p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures">(0)<span class="m_644375482325041305m_-7593936103680568924gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>VisibilityKilometers = "VisibilityKilometers"</span></p>
<p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures">(1)<span class="m_644375482325041305m_-7593936103680568924gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>VisibilityKilometers = 27.4374727668845</span></p>
<p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures">(2)<span class="m_644375482325041305m_-7593936103680568924gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>VisibilityKilometers = 27.4374727668845</span></p>
<p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures">(0)<span class="m_644375482325041305m_-7593936103680568924gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>WindChillC = "WindChillC"</span></p>
<p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures">(1)<span class="m_644375482325041305m_-7593936103680568924gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>WindChillC = 3.52784036047634</span></p>
<p class="m_644375482325041305m_-7593936103680568924gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:19px;line-height:normal;font-family:"Courier New";color:rgb(0,0,0)"><span class="m_644375482325041305m_-7593936103680568924gmail-s1" style="font-variant-ligatures:no-common-ligatures">(2)<span class="m_644375482325041305m_-7593936103680568924gmail-Apple-tab-span" style="white-space:pre-wrap">  </span>WindChillC = 3.52784036047634</span></p></div><div><br></div><div>Thank you for your suggestions.</div><div><br></div><div>Barry</div>-- <br><div dir="ltr" class="m_644375482325041305m_-7593936103680568924gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Associate Scientist, Lecturer,</div><div><div><span style="color:rgb(136,136,136)">The Institute of the Earth Science, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">The Hebrew University of Jerusalem, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Givat Ram, Jerusalem 91904, Israel </span><br style="color:rgb(136,136,136)"></div><span style="color:rgb(136,136,136)">Tel: 972 547 231 170</span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Fax: (972)-25662581</span></div></div><div><span style="color:rgb(136,136,136)"><br></span></div><div>C.E.O, Weather It Is, LTD<br>Weather and Climate Focus<br><a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>Jerusalem, Israel<br>Local: 02 930 9525<br>Cell: 054 7 231 170<br>Int-IS: x972 2 930 9525<br>Hello:</div><div><br></div><div><br></div></div></div></div></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Associate Scientist, Lecturer,</div><div><div><span style="color:rgb(136,136,136)">The Institute of the Earth Science, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">The Hebrew University of Jerusalem, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Givat Ram, Jerusalem 91904, Israel </span><br style="color:rgb(136,136,136)"></div><span style="color:rgb(136,136,136)">Tel: 972 547 231 170</span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Fax: (972)-25662581</span></div></div><div><span style="color:rgb(136,136,136)"><br></span></div><div>C.E.O, Weather It Is, LTD<br>Weather and Climate Focus<br><a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>Jerusalem, Israel<br>Local: 02 930 9525<br>Cell: 054 7 231 170<br>Int-IS: x972 2 930 9525<br><br></div></div></div></div></div>