read and write csv format file

From: Luo, Chao <chao.luo_at_nyahnyahspammersnyahnyah>
Date: Mon Oct 01 2012 - 17:45:21 MDT

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
Received on Tue Oct 2 01:45:31 2012

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