Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.
|
|
Pg
Posts:
139
Registered:
1/24/09
|
|
Traversing thru folder
Posted:
Aug 27, 2013 9:58 AM
|
|
Hi,
I have 9 different folder describing different regions. Inside each folder i have some 100's of text file which i need to read and do further processing. But i need my program automatically do all these operation. I wrote following code for that:
list = dir('my path name'); isub = [list(:).isdir]; Region = {list(isub).name}'; % extracting region name Region(ismember(Region,{'.','..'})) = [];
for idx = 1:length(Region) waitbar(idx/length(Region)) Station_name = dir(sprintf(Region{idx,1})); % displaying list of .text file in folder StationIndex = find(~[Station_name.isdir]); Region_name = sprintf(Region{idx,1}); for i = 1:length(StationIndex) Station = Station_name(StationIndex(i)).name fprintf('Region name = %s, Station name = %s\n',Region{idx,1}, Station); % displaying each station name end end
But the problem is as my region name is variable (which is 9 in this case, the 9 different folder) I am unable to load the data from each different folder, which is stored in text format. After fprintf command I need to read this text files from individual folders. I tried with load, which didn't work for me. The error i'm getting:
Unable to read file '107188.txt': no such file or directory.
because this file is in one of the folder, whose index is idx = 1 in this case, Pls. help how i can address this issue. Thanks,
|
|
|
|