Is there a way in gauss to load multiple excel files using
do while loop?
I have many excel file called file(1), file(2), ...file(n)
I wrote the following code:
i=1; y=zeros(bigt,n); do while i<=n; data=xlsreadm(file(i), "A1:A100",1); y[.,i]=data; i=i+1; endo;
The error message I get is that
file(i) is not found. My code may be incorrect. Any help, suggestion or alternative way to compile and merge data from multiple files is appreciated.
Thanks in advance
If you are getting the
file not found error, it could be that:
- Your working directory is different than the directory of your files and you did not add a path to the file names.
- The path was incorrect.
Here is an example using GAUSS example files that works.
new; fnames = "xle_daily.xlsx" $| "tbill_3mo.xlsx"; // Add full path path = getGAUSSHome() $+ "examples/"; fnames = path $+ fnames; // Print names for verification print fnames; y = zeros(rows(fnames), 10); for i(1, rows(fnames), 1); // Read a 10 element column vector. // Transpose and write to 'y' y[i,.] = xlsReadM(fnames[i], "B2:B11")'; endfor; print y;
Thanks for your help.