[gradsusr] reading a CSV
Stephen McMillan
smcmillan at planalytics.com
Thu Sep 3 17:33:48 EDT 2015
Hi Jeff,
Bill R's suggestion may be the simplest and quickest but, if you need to
keep the commas in there, you could write a function that uses a
combination of sublin and substr (a character at a time) to location the
positions of the commas, then use that information and substr to extract
the data between them. For example, let's say p1=10 and p2=18 (positions
of successive commas), then you could do something like this:
pcpn=substr(lineofdata,'p1+1','lof') where "lineofdata" is your read-in
record and lof=p2-p1-1 (length of field)
then repeat until there are no commas left in the line. Repeat for each
successive record.
Stephen Mc
On Thu, Sep 3, 2015 at 4:44 PM, Bill Reilly <bill_reilly at compuserve.com>
wrote:
> Jeff:
>
> You can try replacing all the commas with spaces first (using a text
> editor or command line function) and then you can use the subwrd()
> command like normal.
>
> Bill
>
> --
>
> Bill Reilly
> (+34) 686-110-748
>
> bill at passageweather.com
> www.passageweather.com
>
> bill at brwebworks.com
> www.brwebworks.com
>
> On 9/3/2015 9:17 PM, Jeff Duda wrote:
> > Is there a simple function in Grads to read text data from a csv file?
> > The intrinsic function read() offers an advantage for files with
> > spaces, making the subwrd() command particularly useful. However, when
> > there are no spaces, obtaining specific columns, especially when the
> > number of digits used to express the data is not the same between
> > different records, becomes quite tedious. There must be something that
> > already exists that's simpler than what I'm currently doing.
> >
> > Jeff Duda
> >
> > --
> > Jeff Duda
> > Graduate research assistant
> > University of Oklahoma School of Meteorology
> > Center for Analysis and Prediction of Storms
> >
> >
> > _______________________________________________
> > gradsusr mailing list
> > gradsusr at gradsusr.org
> > http://gradsusr.org/mailman/listinfo/gradsusr
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20150903/aef593c7/attachment.html
More information about the gradsusr
mailing list