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?
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:
unemployment.xls gdp.xls inflation.xls
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
Please login or Register to submit your answer