<div dir="ltr"><div>Hi,</div><div><br></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></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></div><div><br></div><div><a 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></div><div>Hope that helps,</div><div>Rick<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 6, 2020 at 8:18 AM Ehsan Taghizadeh via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_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></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></div><div>;-Read fields</div><div> pr<span style="white-space:pre-wrap"> </span>= tofloat(str_get_field(lnst(1:),7, delim))<br></div><div><br></div><div><br></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></div><div><br></div></div>I've attached a sample input file and I'll be thankful if I hear from you.</div><div dir="ltr"><br></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>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>