Re: csv files

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Mon Aug 09 2010 - 08:56:48 MDT

Ben,

In your script, change these two lines:
c1 = str_get_field(infile(1:), 1, delim)
c2 = str_get_field(infile(1:), 2, delim)

to:
c1 = str_get_field(Accra_rr(1:), 1, delim)
c2 = str_get_field(Accra_rr(1:), 2, delim)

Then it will work.

You are suppose to process the strings, with string function,
not the file.

Wei

huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924

On Aug 9, 2010, at 2:42 AM, Benjamin Lamptey wrote:

> Wei,
> Good morning. This is what I get when I try your suggestion.
>
> xxxxxxx
> Copyright (C) 1995-2010 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.2.1
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> warning:asciiread: No elements read from file, returning a single
> element with the default missing value for the requested type
>
>
> Variable: Accra_rr
> Type: string
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) missing
> fatal:Subscript out of range, error in subscript #0
> fatal:An error occurred reading infile
> fatal:Execute: Error occurred at or near line 22 in file prelim.ncl
> xxxxxxxxxxxxxx
>
> Kindly use the attached ncl script and the data I sent in my first
> email to try out your thoughts and see.
>
> Thanks
> Ben
> On Fri, Aug 6, 2010 at 4:31 PM, Wei Huang <huangwei@ucar.edu> wrote:
> Ben,
>
> Try this script:
>
> strs = asciiread("tst.txt", -1, "string")
> delim = str_get_tab()
> c1 = str_get_field(strs(1:), 1, delim)
> c2 = str_get_field(strs(1:), 2, delim)
>
> print(c1)
> print(c2)
>
> (Certainly, you need to change tst.txt to your own file name).
>
> Regards,
>
> Wei
>
> huangwei@ucar.edu
> VETS/CISL
> National Center for Atmospheric Research
> P.O. Box 3000 (1850 Table Mesa Dr.)
> Boulder, CO 80307-3000 USA
> (303) 497-8924
>
>
>
>
>
> On Aug 6, 2010, at 10:00 AM, Benjamin Lamptey wrote:
>
>> Hello,
>> I have some .csv file which looks like the following
>>
>>
>> Date RR
>> 1-Jan-60 0
>> 2-Jan-60 0
>> 3-Jan-60 0
>> 4-Jan-60 0
>> 5-Jan-60 0
>> 6-Jan-60 0
>> 7-Jan-60 0
>> 8-Jan-60 0
>> 9-Jan-60 0
>> 10-Jan-60 0
>> 11-Jan-60 0
>> 12-Jan-60 0
>> 13-Jan-60 0
>> 14-Jan-60 0
>> 15-Jan-60 3.8
>> 16-Jan-60 0
>> 17-Jan-60 0
>> 18-Jan-60 0
>> 19-Jan-60 0
>> 20-Jan-60 0
>> 21-Jan-60 0
>> 22-Jan-60 0
>> 23-Jan-60 0
>> 24-Jan-60 0
>> 25-Jan-60 0
>> 26-Jan-60 0
>> 27-Jan-60 0
>> 28-Jan-60 0
>> 29-Jan-60 0
>> 30-Jan-60 0
>> 31-Jan-60 0
>> 1-Feb-60 0
>> 2-Feb-60 0
>> 3-Feb-60 0
>> 4-Feb-60 3.8
>>
>>
>> I have tried using the examples on the reading csv files page
>> without success.
>> The date is not read in properly.
>>
>> Could someone kindly help me out?
>>
>> Thanks
>> Ben
>>
>> Benjamin Lamptey, PhD
>> Senior Lecturer
>> Nautical Science Department
>> Regional Maritime University
>> P.O. Box GP 1115, Accra Ghana
>>
>> and
>>
>> Scientist (Meteorologist and Geoscientist)
>> International Water Management Institute
>> PMB CT 112, Cantonments, Accra Ghana
>> FAX: +233 030 2 784752
>>
>> Cell: +233(0)273135062
>> bllamptey@gmail.com
>> http://www.rap.ucar.edu/~lamptey
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> Benjamin Lamptey, PhD
> Senior Lecturer
> Nautical Science Department
> Regional Maritime University
> P.O. Box GP 1115, Accra Ghana
>
> and
>
> Scientist (Meteorologist and Geoscientist)
> International Water Management Institute
> PMB CT 112, Cantonments, Accra Ghana
> FAX: +233 030 2 784752
>
> Cell: +233(0)273135062
> bllamptey@gmail.com
> http://www.rap.ucar.edu/~lamptey
>
> <prelim.ncl>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Aug 9 08:56:57 2010

This archive was generated by hypermail 2.1.8 : Tue Aug 17 2010 - 15:33:24 MDT