[ncl-talk] Sub:Read CSV
Mary Haley
haley at ucar.edu
Tue Nov 28 09:44:24 MST 2017
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/20171128/daecbb5c/attachment.html>
More information about the ncl-talk
mailing list