<div dir="ltr"><div><div class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Dear NCL-experts,</div><div><br></div><div>I am trying to read and process multiple csv files. Here is my script:</div><div><br></div><div><br></div><div><div>begin</div><div> diri = "./"</div><div> files = systemfunc("ls *.csv")</div><div> numfiles = dimsizes(files)</div><div> do ifil = 0,numfiles-1</div><div> lines = asciiread(files(ifil),-1,"string")</div><div> data = lines(1:)</div><div> ;print(data)</div><div> rain = tofloat(str_get_field(data,1,","))</div><div>;;***************************************************</div><div>;;Apply 1-2-1 running average (three pentads)</div><div>;;****************************************************</div><div> x = wgt_runave(rain, (/0.25, 0.50, 0.25/), 0)</div><div> x@_FillValue = -9999</div><div>;;****************************************************</div><div>;;Save output to a csv file</div><div>;;****************************************************</div><div> flname = files(ifil)+"_filt.csv"</div><div> asciiwrite(flname,x)</div><div> end do</div><div>end</div></div><div><br></div><div><br></div><div>Question:</div><div><br></div><div>[1] The output of this script is like this:</div><div><b><br></b></div><div><b>sg_X1980.csv_filt.csv</b><br></div><div><b><br></b></div><div>I want the output to be like : sg_X1980_filt.csv</div><div><br></div><div>Is there a way to "cut" or "select" specific strings from the input filename and use it for the output filename. </div><div><br></div><div>I'll appreciate any help.</div><div><br></div><div>Sincerely,</div><div><br></div><div>Lyndz</div><div><br></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div></div>
</div>