Re: read and write csv format file

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Mon Oct 01 2012 - 17:57:11 MDT

y has two dimensions, but you are giving only 1 subscript in
asciiwrite. See the examples on the web page for str_split_csv. To
write columns 7 and 34, use these subscripts:

y(6,:)
y(33,:)

--Dave

On Mon, Oct 1, 2012 at 5:45 PM, Luo, Chao <chao.luo@eas.gatech.edu> wrote:
> Hi,
>
> I am trying to read and write part of the csv file. The csv file includes
> string, blank space, integer number, real number mixed. I want to write some
> columns (column 7 (string), and column 34 (number) ) with string and
> number. The error message like:
>
> fatal:Number of subscripts do not match number of dimensions of variable,(1)
> Subscripts used, (2) Subscripts expected. Any help are very appreciated!
>
> CL
>
>
> -----------------------------------
> here is the scripts I used:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> begin
> filename = "../../dat/2012-MarApr-GFCPermits.csv"
>
> ;---Read in file as array of strings so we can parse each line
> lines = asciiread(filename,-1,"string")
>
> delim = ","
>
> y = str_split_csv(lines, ",", 0)
>
> asciiwrite("tst.txt1",y(6)) ;;; write string
> asciiwrite("tst.txt2",y(33)) ;;; write integer number
>
> end
> -----------------------------------------
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Oct 2 01:57:21 2012

This archive was generated by hypermail 2.1.8 : Tue Oct 02 2012 - 13:38:41 MDT