[ncl-talk] How to select specific strings from input filenames and use it for output filenames
Lyndon Mark Olaguera
olagueralyndonmark429 at gmail.com
Sun Sep 24 23:20:21 MDT 2017
Dear NCL-experts,
I am trying to read and process multiple csv files. Here is my script:
begin
diri = "./"
files = systemfunc("ls *.csv")
numfiles = dimsizes(files)
do ifil = 0,numfiles-1
lines = asciiread(files(ifil),-1,"string")
data = lines(1:)
;print(data)
rain = tofloat(str_get_field(data,1,","))
;;***************************************************
;;Apply 1-2-1 running average (three pentads)
;;****************************************************
x = wgt_runave(rain, (/0.25, 0.50, 0.25/), 0)
x at _FillValue = -9999
;;****************************************************
;;Save output to a csv file
;;****************************************************
flname = files(ifil)+"_filt.csv"
asciiwrite(flname,x)
end do
end
Question:
[1] The output of this script is like this:
*sg_X1980.csv_filt.csv*
I want the output to be like : sg_X1980_filt.csv
Is there a way to "cut" or "select" specific strings from the input
filename and use it for the output filename.
I'll appreciate any help.
Sincerely,
Lyndz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170925/893c659e/attachment.html>
More information about the ncl-talk
mailing list