[ncl-talk] asciiread
Rick Brownrigg
brownrig at ucar.edu
Tue Oct 6 08:43:10 MDT 2020
Hi,
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 ",,"
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
http://ncl.ucar.edu/Document/Functions/Built-in/str_get_field.shtml
Hope that helps,
Rick
On Tue, Oct 6, 2020 at 8:18 AM Ehsan Taghizadeh via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:
> Dears,
> 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.
>
> f = "ncl.csv"
> lnst = asciiread(f,-1,"string")
> delim = ","
>
> ;-Read fields
> pr = tofloat(str_get_field(lnst(1:),7, delim))
>
>
> error:
> warning: tofloat: A bad value was passed to (string) tofloat, input
> strings must contain numeric digits, replacing with missing value
>
> I've attached a sample input file and I'll be thankful if I hear from you.
>
> *Sincerely,*
> *Ehsan Taghizadeh*
> *University of Tehran, Iran*
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20201006/24af25bb/attachment.html>
More information about the ncl-talk
mailing list