<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Yes there is,<div class="">see here <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/str_sub_str.shtml" class="">https://www.ncl.ucar.edu/Document/Functions/Built-in/str_sub_str.shtml</a> and here <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/str_split_by_length.shtml" class="">https://www.ncl.ucar.edu/Document/Functions/Built-in/str_split_by_length.shtml</a>. <br class=""><div><blockquote type="cite" class=""><div class="">Il giorno 25 set 2017, alle ore 07:20, Lyndon Mark Olaguera <<a href="mailto:olagueralyndonmark429@gmail.com" class="">olagueralyndonmark429@gmail.com</a>> ha scritto:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">Dear NCL-experts,</div><div class=""><br class=""></div><div class="">I am trying to read and process multiple csv files. Here is my script:</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">begin</div><div class=""> diri = "./"</div><div class=""> files = systemfunc("ls *.csv")</div><div class=""> numfiles = dimsizes(files)</div><div class=""> do ifil = 0,numfiles-1</div><div class=""> lines = asciiread(files(ifil),-1,"string")</div><div class=""> data = lines(1:)</div><div class=""> ;print(data)</div><div class=""> rain = tofloat(str_get_field(data,1,","))</div><div class="">;;***************************************************</div><div class="">;;Apply 1-2-1 running average (three pentads)</div><div class="">;;****************************************************</div><div class=""> x = wgt_runave(rain, (/0.25, 0.50, 0.25/), 0)</div><div class=""> x@_FillValue = -9999</div><div class="">;;****************************************************</div><div class="">;;Save output to a csv file</div><div class="">;;****************************************************</div><div class=""> flname = files(ifil)+"_filt.csv"</div><div class=""> asciiwrite(flname,x)</div><div class=""> end do</div><div class="">end</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Question:</div><div class=""><br class=""></div><div class="">[1] The output of this script is like this:</div><div class=""><b class=""><br class=""></b></div><div class=""><b class="">sg_X1980.csv_filt.csv</b><br class=""></div><div class=""><b class=""><br class=""></b></div><div class="">I want the output to be like : sg_X1980_filt.csv</div><div class=""><br class=""></div><div class="">Is there a way to "cut" or "select" specific strings from the input filename and use it for the output filename. </div><div class=""><br class=""></div><div class="">I'll appreciate any help.</div><div class=""><br class=""></div><div class="">Sincerely,</div><div class=""><br class=""></div><div class="">Lyndz</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></div></div></div></div></div></div></div>
</div>
_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""></div></blockquote></div><br class=""></div></body></html>