Re #14: I don't see anything wrong with your code, and when I tried it on my setup it ran with no problems and produced the expected results. I cannot replicate your problem.
-
Login or Register
- Log in with
* Get a list of all the relevant files in your directory clear all cd "\\m\TWSE\20014_01" local flist: dir "." files "*.csv" * Import each file in the list and save it to a tempfile local nfile 0 foreach fname of local flist { local ++nfile import delimited "`fname'", bindquote(strict) case(preserve) clear tempfile temp`nfile' save "`temp`nfile''" } * Append all of the nfile files clear forval i = 1/`nfile' { append using "`temp`i''" } save alldata, replace
local flist: dir "." files "*.xlsx" local nfile 0 foreach fname of local flist { local ++nfile import excel "`fname'", sheet("page_1") firstrow case(lower) clear local datestring = subinstr("`fname'", ".xlsx", "", .) // save "temp`nfile'", replace global FilesLeft = `nfile' } local nfile = $FilesLeft - 1 forvalues i = `nfile'(-1)1 { display "Appending file `i'" append using "temp`i'" } local nfile = $FilesLeft forvalues i = `nfile'(-1)1 { . rm temp`i'.dta }
Comment