I want to import a series of files with similar filenames that change according to a "ticker". An example is filenames A1_data.dat
, B2_data.dat
, C3_data.dat
etc. The ticker is a list of text values ticker={"A1","B2","C3"}
The following line of code works fine, for the appropriate file path (all files are in the same folder).
ticker = {"A1", "B2", "C3"};
Table[Import[FileNameJoin[{"C:\\Users\\Cartman\\Desktop\\data",
StringReplace["ticker_data.dat", "ticker" -> ticker[[i]]]}], "Table"], {i, 1, 3}]
However, I was wondering how this can be written without a loop structure such as Table
or Do
but by setting an appropriate function and using e.g. Map
. The idea is to change the ticker part of the file path in Import
"C:\\Users\\Cartman\\Desktop\\data\\TICKER_data.dat"