How to specify the input folder location and save output in specified folder
17 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Kanakaiah Jakkula
il 26 Feb 2016
Commentato: Kanakaiah Jakkula
il 26 Feb 2016
Hi,
I have the following code:
clc;
clear all;
close all;
filename='tool1.xlsx';
[score, M]=xlsread(filename);
M(1,:)=[];
M(:,1)=[];
M(:,3)=[];
score(:,2:3)=[];
filterdata=[M num2cell(score)];
outputfilename=regexp(filename,'.xlsx','split');
outputdatafilename=['output_' outputfilename{1} '.xlsx'];
xlswrite(outputdatafilename,filterdata)
(1) I want to put input data in one folder and save out put in another (specified folder). Pl help how can I do this.
(2) I want to read all '.xlsx' files in a given folder one by one and save corresponding output in another specified folder. Pl also help how can I do this( I have give two tool's data).
Sincerely, Mekala
0 Commenti
Risposta accettata
Guillaume
il 26 Feb 2016
Modificato: Guillaume
il 26 Feb 2016
sourcefolder = 'C:\some\folder';
destinationfolder = 'C:\some\other\folder';
[score, M] = xlsread(fullfile(sourcefolder, filename));
%...
xlswrite(fullfile(destinationfolder, outputdatafilename), filterdata);
sourcefolder = 'C:\some\folder';
fcontent = dir(fullfile(sourcefolder, '*.xlsx')); %fcontent is a column vector of structures
for file = fcontent'
filename = file.name;
[score, M] = xlsread(fullfile(sourcefolder, filename));
%...
end
[~, outputfilename] = fileparts(filename);
outputdatafilename = sprintf('output_%s.xlsx' outputfilename);
Although in your case, I don't understand why you're removing the '.xlsx' only to add it back on the next line, so you might as well simply do:
outputdatafilename = ['output_' filename];
3 Commenti
Guillaume
il 26 Feb 2016
Well, you specify it in xlswrite of course. I simply forgot to include it in my example.
Fixed now.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Import and Analysis in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!