Hi everyone, I am trying to loop over a bunch of csv files, make some changes and save them as csv files.
Currently I have this code:
local files : dir "C:\Users\mydir" files "*.csv"
cd "C:\Users\mydir"
foreach file of local files {
import delimited `file', clear
//do something
export delimited using "`file'", replace
}
It gives me an error which I believe is because the file names have spaces in them. Could you help me fix this, please?
Also, if I wanted to save them under a different name, rather than overwriting, how could I do that? Would something like
export delimited using "`file'_new" work?
Many thanks for your help.
Currently I have this code:
local files : dir "C:\Users\mydir" files "*.csv"
cd "C:\Users\mydir"
foreach file of local files {
import delimited `file', clear
//do something
export delimited using "`file'", replace
}
It gives me an error which I believe is because the file names have spaces in them. Could you help me fix this, please?
Also, if I wanted to save them under a different name, rather than overwriting, how could I do that? Would something like
export delimited using "`file'_new" work?
Many thanks for your help.
Comment