<html><head></head><body><div class="ydpe7ed841cyahoo-style-wrap" style="font-family: bookman old style, new york, times, serif; font-size: 16px;"><div style="font-size: 16px;"></div>
        <div dir="ltr" data-setdir="false" style="font-size: 16px;">Dear Rick,</div><div dir="ltr" data-setdir="false" style="font-size: 16px;">Thank you so much for your nice help. It seems to work for stringtoint but not for stringtofloat!</div><div style="font-size: 16px;"><br></div><div style="font-size: 16px;"><br></div><div dir="ltr" data-setdir="false" style=""><i style=""><font size="2">Sincerely,</font></i></div><div dir="ltr" data-setdir="false" style=""><i style=""><font size="2">Ehsan</font></i></div>
        
        </div><div id="yahoo_quoted_2734002388" class="yahoo_quoted">
            <div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
                
                <div>
                    On Tuesday, October 6, 2020, 06:13:23 PM GMT+3:30, Rick Brownrigg <brownrig@ucar.edu> wrote:
                </div>
                <div><br></div>
                <div><br></div>
                <div><div id="yiv3065514746"><div><div dir="ltr"><div>Hi,</div><div><br clear="none"></div><div>At least part of the issue is that your file has consecutive delimiters, and str_get_field treats those as one (I did not know that!), so parsing the columns gets out of sync on lines with ",,"</div><div><br clear="none"></div><div>See example 5 at the link below for how to deal with this. It essentially uses str_sub_str()  to textually replace instances of ",," with some appropriate _FillValue. It does this in the strings returned from asciiread() and then attempts to parse using str_get_field<br clear="none"></div><div><br clear="none"></div><div><a rel="nofollow" shape="rect" target="_blank" href="http://ncl.ucar.edu/Document/Functions/Built-in/str_get_field.shtml">http://ncl.ucar.edu/Document/Functions/Built-in/str_get_field.shtml</a></div><div><br clear="none"></div><div>Hope that helps,</div><div>Rick<br clear="none"></div><div><br clear="none"></div></div><br clear="none"><div class="yiv3065514746gmail_quote"><div class="yiv3065514746yqt5000476810" id="yiv3065514746yqt16042"><div class="yiv3065514746gmail_attr" dir="ltr">On Tue, Oct 6, 2020 at 8:18 AM Ehsan Taghizadeh via ncl-talk <<a rel="nofollow" shape="rect" ymailto="mailto:ncl-talk@mailman.ucar.edu" target="_blank" href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br clear="none"></div><blockquote class="yiv3065514746gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="font-family:bookman old style, new york, times, serif;font-size:16px;"><div dir="ltr">Dears,</div><div dir="ltr">I would like to read a ".csv" file including different fields. Some arrays have no data and are empty. May I ask how I handle this file? I've tried the following lines, but I got the following warning because of arrays with no data.</div><div dir="ltr"><br clear="none"></div><div dir="ltr"><div><div>  f = "ncl.csv"</div><div>  lnst<span style="white-space:pre-wrap;"> </span>= asciiread(f,-1,"string")</div><div>  delim = ","</div><div><br clear="none"></div><div>;-Read fields</div><div>  pr<span style="white-space:pre-wrap;">        </span>= tofloat(str_get_field(lnst(1:),7, delim))<br clear="none"></div><div><br clear="none"></div><div><br clear="none"></div><div dir="ltr">error:</div><div dir="ltr"><span>warning: tofloat: A bad value was passed to (string) tofloat, input strings must contain numeric digits, replacing with missing value</span><br clear="none"></div><div><br clear="none"></div></div>I've attached a sample input file and I'll be thankful if I hear from you.</div><div dir="ltr"><br clear="none"></div><div dir="ltr"><i><font size="2">Sincerely,</font></i></div><div dir="ltr"><i><font size="2">Ehsan Taghizadeh</font></i></div><div dir="ltr"><i><font size="2">University of Tehran, Iran</font></i></div></div></div>_______________________________________________<br clear="none">
ncl-talk mailing list<br clear="none">
<a rel="nofollow" shape="rect" ymailto="mailto:ncl-talk@mailman.ucar.edu" target="_blank" href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a><br clear="none">
List instructions, subscriber options, unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div></div></div></div></div>
            </div>
        </div></body></html>