[ncl-talk] Sub:Read CSV

dale zuri dalezuri at gmail.com
Sun Jan 7 20:28:50 MST 2018


Hi ,
Thanks.  I would like to extract specific row by specific column.
For example, leaving the date column extracting the first 10 rows and 25
columns.
I couldn't leave the date column. Could someone help me to figure it out?

Dz


On Tue, Nov 28, 2017 at 7:44 AM Mary Haley <haley at ucar.edu> wrote:

> Hi,
>
> For CSV data, I recommend using str_split_csv to extract the data:
>
> infile1 = "AK_BackCast_StnData-Temp.csv"
> lines1  = asciiread (infile1, -1, "string")
> delim = ","
>
> ;months starts in column #0
>
> csv_lines = str_split_csv(lines1(2:),delim,0)
> date      = csv_lines(:,0)          ; first column
> col2      = toint(csv_lines(:,1))   ; second column
> col3      = toint(csv_lines(:,2))   ; third column
>
> print(col3)    ; use "tofloat" in place of "toint" if you want floating
> point data
>
> --Mary
>
>
> On Mon, Nov 27, 2017 at 4:25 PM, dale zuri <dalezuri at gmail.com> wrote:
>
>> Hi ,
>> I have an issue with reading the CSV.
>>
>> I would appreciate any help and suggestions.
>>
>> Thanks
>> begin
>>
>>
>> infile1 = "AK_BackCast_StnData-Temp.csv"
>> lines1  = asciiread (infile1, -1, "string")
>> print(lines1)
>> delim = ","
>> ;months starts in field number 1
>> name  =  str_get_field(lines1,3,delim)
>> print(name)
>>
>> I want to read each column with associated string field.
>> Except number 1 and 2, the rest of the field numbers are not correct. For
>> example, number 3 field, print the different column.
>>
>> I don't understand whats happening here.
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180108/2f6cef88/attachment.html>


More information about the ncl-talk mailing list