<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">Hi:</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> All,I have write a script to read and calculate .csv data according to the "Reading csv"<SPAN style="LINE-HEIGHT: 1.5">example on the NCL website,but it appears fatal :</SPAN></DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><BR></DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">
<DIV style="LINE-HEIGHT: 23px">fatal:Dimension sizes of left hand side and right hand side of assignment do not match<BR>fatal:["Execute.c":8567]:Execute: Error occurred at or near line 45 in file csv_read.ncl<BR></DIV>
<DIV><BR></DIV></DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">The line 45 is ' lines = asciiread(filename1(i),-1,"string")' ........</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">.........</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">........</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">But when I try to read only one csv data,the script can work out.</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">I don't know how to fix this,can you guys help me?</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">My csv date stored like this:</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">
<DIV><IMG src="cid:EB46180F@369E5746.B1061858"></DIV>
<DIV>Each file include some same named csv data:</DIV>
<DIV>
<DIV><IMG src="cid:8F3DDE0B@369E5746.B1061858"><IMG style="LINE-HEIGHT: 1.5" src="cid:BF98B23B@369E5746.B1061858"></DIV></DIV>
<DIV><BR></DIV>
<DIV>Can you help me or give me some good idea?</DIV></DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><BR></DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">This is my script:</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> </DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">;<BR>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<BR>begin<BR> filename1=systemfunc("ls /public/home/huanglei/cmaqdata/2016*/Zhouzhi.csv")<BR> ; fin1=addfiles(filename1,"r")<BR> ; printVarSummary(filename1)<BR> print(filename1)<BR> <BR> ; exit<BR> filenumber =38<BR> time_al= new((/filenumber/),string,"No_FillValue")<BR> oth_al = new((/filenumber/),float,"No_FillValue")<BR> xa_al = new((/filenumber/),float,"No_FillValue")<BR> tc_al = new((/filenumber/),float,"No_FillValue")<BR> bj_al = new((/filenumber/),float,"No_FillValue")<BR> xy_al = new((/filenumber/),float,"No_FillValue")<BR> wn_al = new((/filenumber/),float,"No_FillValue")<BR> ya_al = new((/filenumber/),float,"No_FillValue")<BR> hz_al = new((/filenumber/),float,"No_FillValue")<BR> yl_al = new((/filenumber/),float,"No_FillValue")<BR> ak_al = new((/filenumber/),float,"No_FillValue")<BR> sl_al = new((/filenumber/),float,"No_FillValue")<BR> <BR> do i=0,filenumber-1<BR> <BR> ;---Read in file as array of strings so we can parse each line.<BR> ; printVarSummary(filename1(2))<BR> lines = asciiread(filename1(i),-1,"string")<BR> nlines = dimsizes(lines)-1 ; First line is a header</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> ;<BR> ; Start reading in the fields we care about:<BR> ; The first line is a header, so skip this.<BR> ;<BR> delim = ","<BR> time = str_get_field(lines(13:36),1,delim) <BR> oth = str_get_field(lines(13:36),2,delim) <BR> xa = str_get_field(lines(13:36),3,delim) <BR> tc = str_get_field(lines(13:36),4,delim) <BR> bj = str_get_field(lines(13:36),5,delim) <BR> xy = str_get_field(lines(13:36),6,delim) <BR> wn = str_get_field(lines(13:36),7,delim) <BR> ya = str_get_field(lines(13:36),8,delim)<BR> hz = str_get_field(lines(13:36),9,delim) <BR> yl = str_get_field(lines(13:36),10,delim) <BR> ak = str_get_field(lines(13:36),11,delim) <BR> sl = str_get_field(lines(13:36),12,delim)<BR> ; print(time)<BR> ; exit<BR> ; time_al(i,:)= time <BR> ; print(time_al(i,:))<BR> oth_al(i) =sum(stringtofloat(oth)) <BR> xa_al(i) = sum(stringtofloat(xa)) <BR> tc_al(i) = sum(stringtofloat(tc)) <BR> bj_al(i) = sum(stringtofloat(bj)) <BR> xy_al(i) = sum(stringtofloat(xy)) <BR> wn_al(i) = sum(stringtofloat(wn)) <BR> ya_al(i) = sum(stringtofloat(ya)) <BR> hz_al(i) = sum(stringtofloat(hz)) <BR> yl_al(i) = sum(stringtofloat(yl)) <BR> ak_al(i) = sum(stringtofloat(ak)) <BR> sl_al(i) = sum(stringtofloat(sl)) <BR> ; print(oth_al(i)) <BR> ;exit<BR> end do</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> ; time_all=ndtooned(time_al)<BR> oth_all=ndtooned(oth_al)<BR> xa_all=ndtooned(xa_al)<BR> tc_all=ndtooned(tc_al)<BR> bj_all=ndtooned(bj_al)<BR> xy_all=ndtooned(xy_al)<BR> wn_all=ndtooned(wn_al)<BR> ya_all=ndtooned(ya_al)<BR> hz_all=ndtooned(hz_al)<BR> yl_all=ndtooned(yl_al) <BR> ak_all=ndtooned(ak_al)<BR> sl_all=ndtooned(sl_al) </DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><BR> print(oth_all)<BR> ; exit<BR> ; calculate the avg</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> oth_avg=avg(oth_all)<BR> xa_avg=avg(xa_all)<BR> tc_avg=avg(tc_all)<BR> bj_avg=avg(bj_all)<BR> xy_avg=avg(xy_all)<BR> wn_avg=avg(wn_all)<BR> ya_avg=avg(ya_all)<BR> hz_avg=avg(hz_all)<BR> yl_avg=avg(yl_all) <BR> ak_avg=avg(ak_all)<BR> sl_avg=avg(sl_all)</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> ssx = hz_avg + ak_avg + sl_avg<BR> nsx = ya_avg + yl_avg</DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> print("oth="+oth_avg)<BR> print("xa="+xa_avg)<BR> print("tc="+tc_avg)<BR> print("bj="+bj_avg)<BR> print("xy="+xy_avg)<BR> print("wn="+wn_avg)<BR> print("ssx="+ssx)<BR> print("nsx="+nsx)<BR> title = new((/8/),string,"No_FillValue")<BR> title =(/"xa","xy","wn","bj","tc","nsx","ssx","oth"/)<BR> data = new((/8/),float,"No_FillValue")<BR> data =(/xa_avg,xy_avg,wn_avg,bj_avg,tc_avg,nsx,ssx,oth_avg/) <BR> print(data)<BR> ;staname="changan"<BR> output_file="/public/home/huanglei/cmaqdata/final_data/zhouzhi.txt"<BR> write_table(output_file,"w",[/title,data/],"%s%9.5f")<BR>end<BR></DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"> <BR></DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'"><BR></DIV>
<DIV style="LINE-HEIGHT: 23px; FONT-FAMILY: 'lucida Grande', Verdana, 'Microsoft YaHei'">
<DIV style="LINE-HEIGHT: 23px">My NCL version is 6.2.0.</DIV>
<DIV style="LINE-HEIGHT: 23px"> How can I slove the problem?</DIV></DIV>