[ncl-talk] Sub: Reading csv

Adv advita6 at gmail.com
Thu Oct 29 18:23:12 MDT 2015


Hi ,
Sorry. Found a way to do.

Thanks,
Adv

On Thu, Oct 29, 2015 at 4:57 PM, Adv <advita6 at gmail.com> wrote:

> Hi Ncl user,
> This is the code I use to read csv file. I don't understand why it reads
> 23 column as single column. I tried to write it to new file and reading
> again . Then also I stuck with the same issue. I would like to extrack
> specific columns from this file.
>
> Could someone help me?
> Thank you
> Adv
>
> z1 = "minnesota50.csv"
> nrow = numAsciiRow(z1)
> ncol = numAsciiCol(z1)
> ncol=1
> ;
> data = asciiread(z1, (/nrow,ncol/), "string")
> strs = asciiread(z1,-1,"string")
> strs= str_sub_str(strs,"-9999","0")
> strs=str_sub_str(data,",","  ")
> asciiwrite ("county1", strs)
> z2 = "county1"
> nrow1 = numAsciiRow(z2)
> ncol1 = numAsciiCol(z2)
> print(nrow)
> print(ncol)
> return
> ncols = 23
> nhead = 0
> col=15
> data1 = asciiread("county1",(/nrow1,23/),"float")
> ;print(data1)
> dat=data1(0:1,2:2)
> print(dat)
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151029/905c6a34/attachment.html 


More information about the ncl-talk mailing list