loading multiple files at once


Is there a way in gauss to load multiple excel files using do while loop?

for example,

I have many excel file called file(1), file(2), ...file(n)

I wrote the following code:



do while i<=n;

    data=xlsreadm(file(i), "A1:A100",1);




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

2 Answers


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.


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")';

print y;


Thanks for your help.

You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy