# Reading many single files and creating numbered (? or indexed) variable

I tried many different approaches, but I could not solve the following problems, I appreciate your help: What is the best way to read many data files? I mean we have file1.dat, file2.dat, file3.dat …. and I would like to put them in a loop and by using the readlist, import the data, something like what we do in C and sprintf or in bash scripting. I have seen that there is a package which can handle sprintf functionality in Mathematica, but I am looking for simpler solution something like this: (I just used $sign to show what I mean, like bash) Do[d$i = ReadList["/path/file$i.dat", Number, RecordLists -> True], {i, 1, 5}] Can I create a variable like d$i inside the above loop over i? which creates d1, d2, …, and so on, after running the loop?

How can I remove the curly braces from Mean output? I have a single list and the Flatten does not remove the curly braces.

tt = {1, 2, 3, 4, ...}
Flatten[Mean[tt]] = {1234.1234}
-
How are you getting list out of Mean? It normally doesn't return a list, but a number. –  m_goldberg Feb 10 '14 at 15:20
Just using the Mean command for the single list which is created by ReadList. –  Arash Feb 10 '14 at 15:55

You can do something like this:

First create the Symbols for all the variables you need:

dd =  Symbol /@ ("d" <> ToString[#]& /@ Range[5])

ff = "file" <> ToString[#] <> ".dat" & /@ Range[5]