Is there a way to retrieve a list of specific file names in a directory?

I would like to have GAUSS get a list of all of the Excel files in a certain directory so that I can iterate over the list and import the data from all of these files. Is there a way to do this?

1 Answer


GAUSS has a command fileSA that will return a list of files matching a certain pattern inside of a separate directory. Suppose that the following files were in the directory C:\gauss13\mydata: unemployment.xls, gdp.xls and inflation.xls then:

xls_files = fileSA("C:\\gauss13\\mydata\\*.xls");

would assign the variable xls_files to be equal to the 3x1 string array:


Now you can pass these filenames into the xlsReadM, or xlsReadSA functions to load their contents into GAUSS.

The star character (*) means any number of any characters. Used alone in the place of the file name fileSA will return all files in a directory. For example (using mac style paths):

all_files = fileSA("/Users/myname/gauss13/mydata/*");

will create the variable all_files as an Nx1 string array with one element for each file in the directory /Users/myname/gauss13/mydata

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.


Thank you for your interest in the GAUSS family of products.

© Aptech Systems, Inc. All rights reserved.

Privacy Policy | Sitemap