I have a series of folders (for example, 50 folders), each with its unique name (completely different names). I want to extract a set of information from each of these folders (from an Excel file). The final output should be an Excel file, that contain all the information extracted from the 50 folders. The data are not numbers. They are E-mails of stuffs. Finally, it should remove duplicate data.
The only common aspect among these 50 folders is that they all contain a folder named "A", and inside this folder, all the necessary information (Excell file with the Emails I want to collect) is placed.
Can anyone help me with this? Thanks in advance.

댓글 수: 2

Image Analyst
Image Analyst 2023년 4월 21일
You posted so soon I really doubt you even had time to run my demos below..

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2023년 4월 21일

1 개 추천

See some file and folder demos, attached. Adapt as needed.

댓글 수: 4

civil tech
civil tech 2023년 4월 21일
I need more help for my task please.
Try this. Adapt as needed to do whatever you want with the data read in from the Excel files.
% Optional initialization steps
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
% Specify the folder where the files live.
myFolder = fullfile(pwd, 'MainFolder'); % or 'C:\Users\whatever\';
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isfolder(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s\nPlease specify a new folder.', myFolder);
uiwait(warndlg(errorMessage));
myFolder = uigetdir(); % Ask for a new one.
if myFolder == 0
% User clicked Cancel
return;
end
end
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '**\*.xlsx'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
allFileNames = fullfile({theFiles.folder}, {theFiles.name})
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
% Read in the next image.
fprintf(1, 'Now reading #%d of %d : "%s"\n', k, length(theFiles), fullFileName);
data = readmatrix(fullFileName);
% Now do something with data.
end
civil tech
civil tech 2023년 4월 22일
Thank you so much for your kind help.
Image Analyst
Image Analyst 2023년 4월 22일
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2023년 4월 21일

댓글:

2023년 4월 22일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by