<div dir="ltr"><div class="gmail_default" style="font-size:small">Grace,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">You can&#39;t open CSV files with addfile or addfiles.  These two functions are for &quot;supported file formats&quot; which are defined as NetCDF, GRIB 1/2, HDF 4/5, HDF-EOS 2/5, and shapefile.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I think your script is mostly correct, as you are later reading the file with &quot;asciiread&quot;. This is the proper thing to do since CSV files are considered ASCII files.  </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">To start, you need to remove the &quot;addfiles&quot; call entirely.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Assuming that &quot;filename1&quot; is a list of 29 files, you will also need to change this line:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><div style="font-size:12.8px">       lines  = asciiread(fin1[i],-1,&quot;string&quot;)</div><div><br></div><div>to be:</div><div><br></div><div><div style="font-size:12.8px">       lines  = asciiread(filename1(i),-1,&quot;string&quot;)</div></div><div><br></div><div>--Mary</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jun 19, 2016 at 9:53 PM, grace <span dir="ltr">&lt;<a href="mailto:313695096@qq.com" target="_blank">313695096@qq.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Hi:</div><div>  All,I have write a script to read and calculate .csv data according to the &quot;Reading csv&quot;<span style="line-height:1.5">example on the NCL website,but it appears warning and fatal:</span></div><div><br></div><div> warning:[&quot;FileSupport.c&quot;:3894]:NCL does not know anything about file suffix &lt;csv&gt;. </div><div> But NCL will try its best to figure out the file format.</div><div><br></div><div> fatal:An internal error has occurred. The file format requested does not appear to be supported, could not open (/public/home/huanglei/cmaqdata/20160615/Caotan.csv)</div><div> warning:[&quot;FileSupport.c&quot;:3894]:NCL does not know anything about file suffix &lt;csv&gt;. </div><div> But NCL will try its best to figure out the file format.</div><div> ........</div><div>.........</div><div>........</div><div><br></div><div><br></div><div>This is my script:</div><div>   ;</div><div>begin</div><div><br></div><div> filename1=systemfunc(&quot;ls /public/home/huanglei/cmaqdata/2016*/Caotan.csv&quot;)</div><div>     fin1=addfiles(filename1,&quot;r&quot;)</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">        </span> time_al= new((/29,24/),float,&quot;No_FillValue&quot;)</div><div>     oth_al = new((/29,24/),float,&quot;No_FillValue&quot;)</div><div>     xa_al  = new((/29,24/),float,&quot;No_FillValue&quot;)</div><div>     tc_al  = new((/29,24/),float,&quot;No_FillValue&quot;)</div><div>     bj_al  = new((/29,24/),float,&quot;No_FillValue&quot;)</div><div>     xy_al  = new((/29,24/),float,&quot;No_FillValue&quot;)</div><div>     wn_al  = new((/29,24/),float,&quot;No_FillValue&quot;)</div><div>     ya_al  = new((/29,24/),float,&quot;No_FillValue&quot;)</div><div><span style="white-space:pre-wrap">        </span> hz_al  = new((/29,24/),float,&quot;No_FillValue&quot;)</div><div>     yl_al  = new((/29,24/),float,&quot;No_FillValue&quot;)</div><div>     ak_al  = new((/29,24/),float,&quot;No_FillValue&quot;)</div><div><span style="white-space:pre-wrap">        </span> sl_al  = new((/29,24/),float,&quot;No_FillValue&quot;)</div><div>     do i=0,28</div><div>            </div><div>          ;---Read in file as array of strings so we can parse each line.</div><div>       lines  = asciiread(fin1[i],-1,&quot;string&quot;)</div><div>       nlines = dimsizes(lines)-1   ; First line is a header</div><div><br></div><div>    ;</div><div>    ; Start reading in the fields we care about:</div><div>    ; The first line is a header, so skip this.</div><div>    ;</div><div>      delim     = &quot;,&quot;</div><div>      time = str_get_field(lines(1:25),1,delim)  </div><div>      oth  = str_get_field(lines(1:25),2,delim)  </div><div>      xa   = str_get_field(lines(1:25),3,delim)  </div><div>      tc   = str_get_field(lines(1:25),4,delim)  </div><div><span style="white-space:pre-wrap">        </span>  bj   = str_get_field(lines(1:25),5,delim)  </div><div>      xy   = str_get_field(lines(1:25),6,delim)  </div><div>      wn   = str_get_field(lines(1:25),7,delim)  </div><div>      ya   = str_get_field(lines(1:25),8,delim)</div><div><span style="white-space:pre-wrap">        </span>  hz   = str_get_field(lines(1:25),9,delim)  </div><div>      yl   = str_get_field(lines(1:25),10,delim)  </div><div>      ak   = str_get_field(lines(1:25),11,delim)  </div><div>      sl   = str_get_field(lines(1:25),12,delim)</div><div><br></div><div>            <span style="white-space:pre-wrap">        </span></div><div>             time_al(i,:)= time  <span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">                        </span> oth_al(i,:) = oth  </div><div><span style="white-space:pre-wrap">                        </span> xa_al(i,:)  = xa  </div><div><span style="white-space:pre-wrap">                        </span> tc_al(i,:)  = tc  </div><div><span style="white-space:pre-wrap">                        </span> bj_al(i,:)  = bj  </div><div><span style="white-space:pre-wrap">                        </span> xy_al(i,:)  = xy  </div><div><span style="white-space:pre-wrap">                        </span> wn_al(i,:)  = wn  </div><div><span style="white-space:pre-wrap">                        </span> ya_al(i,:)  = ya  </div><div>             hz_al(i,:)  = tc  </div><div><span style="white-space:pre-wrap">                        </span> yl_al(i,:)  = bj  </div><div><span style="white-space:pre-wrap">                        </span> ak_al(i,:)  = xy  </div><div><span style="white-space:pre-wrap">                        </span> sl_al(i,:)  = wn </div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span> end do</div><div><br></div><div>              time_all=ndtooned(time_al)</div><div><span style="white-space:pre-wrap">                        </span>  oth_all=ndtooned(oth_al)</div><div><span style="white-space:pre-wrap">                        </span>  xa_all=ndtooned(xa_al)</div><div><span style="white-space:pre-wrap">                        </span>  tc_all=ndtooned(tc_al)</div><div><span style="white-space:pre-wrap">                        </span>  bj_all=ndtooned(bj_al)</div><div><span style="white-space:pre-wrap">                        </span>  xy_all=ndtooned(xy_al)</div><div><span style="white-space:pre-wrap">                        </span>  wn_all=ndtooned(wn_al)</div><div>              ya_all=ndtooned(xy_al)</div><div><span style="white-space:pre-wrap">                        </span>  hz_all=ndtooned(wn_al)</div><div><span style="white-space:pre-wrap">                        </span>  yl_all=ndtooned(ya_al)  </div><div><span style="white-space:pre-wrap">                        </span>  ak_all=ndtooned(ak_al)</div><div><span style="white-space:pre-wrap">                        </span>  sl_all=ndtooned(sl_al) </div><div><br></div><div><br></div><div>     print(time_all)</div><div><br></div><div>  ; calculate the avg</div><div><br></div><div>              oth_avg=avg(oth_al)</div><div><span style="white-space:pre-wrap">                        </span>  xa_avg=avg(xa_all)</div><div><span style="white-space:pre-wrap">                        </span>  tc_avg=avg(tc_all)</div><div><span style="white-space:pre-wrap">                        </span>  bj_avg=avg(bj_all)</div><div><span style="white-space:pre-wrap">                        </span>  xy_avg=avg(xy_all)</div><div><span style="white-space:pre-wrap">                        </span>  wn_avg=avg(wn_all)</div><div>              ya_avg=avg(xy_all)</div><div><span style="white-space:pre-wrap">                        </span>  hz_avg=avg(wn_all)</div><div><span style="white-space:pre-wrap">                        </span>  ya_avg=avg(ya_all)  </div><div><span style="white-space:pre-wrap">                        </span>  ak_avg=avg(ak_all)</div><div><span style="white-space:pre-wrap">                        </span>  sl_avg=avg(sl_all)</div><div><br></div><div><span style="white-space:pre-wrap">                        </span>  ssx = hz_avg + ak_avg + sl_avg</div><div><span style="white-space:pre-wrap">                        </span>  nsx = ya_avg + ya_avg</div><div><br></div><div><br></div><div>end</div><div><br></div><div><br></div><div><div style="font-family:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;;line-height:23.7999992370605px">My NCL version is 6.2.0.</div><div style="font-family:&#39;lucida Grande&#39;,Verdana,&#39;Microsoft YaHei&#39;;line-height:23.7999992370605px"> How can I slove the problem?</div></div><div></div><br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>