0
$\begingroup$

I am calculating with the depth data recorded in a number of files with extension .log.

The depth data is like this and I loaded it by means of Mathematica:

Import["C:\\Homeworks\\depth\\file1.log"]
{"2016/01/13 00:00:30", 42, 754}, {"2016/01/13 00:01:00", 42, 754}, 
{"2016/01/13 00:01:30", 42, 753}, {"2016/01/13 00:02:00", 42, 752}, 
{"2016/01/13 00:02:30", 42, 753}, {"2016/01/13 00:03:00", 42, 754}

I succeed in obtaining the depth data and transforming it into 42.754, 42.754, 42.753, 42.752, 42.753, 42.754, etc.

However, this only processes the data in one file. However, I have in my folder a group of about 10 files. How can I read in all the data in a folder in an easier way than to do it individually?

$\endgroup$
1
  • $\begingroup$ Look at the docs for FileNames[ ] , Map[ ] and perhaps Flatten[ ___,1]. Voting to close. $\endgroup$ Feb 11, 2016 at 1:51

1 Answer 1

0
$\begingroup$

In case that your file names are file1.log, file2.log,...,file10.log try the following

Table[Import[i], {i, FileNames["C:\\Homeworks\\depth\\file*.log"]}]

The context of FileName command should be the directory containing your files.

$\endgroup$
1
  • $\begingroup$ Absolutely, Mr. demm your answer captured the main problem. Dr. Belisaruis Flatten[ __,1] was also nice trick. $\endgroup$
    – Mehmet
    Feb 11, 2016 at 3:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.