How to read CSV file and save the result to another CSV file
4 views (last 30 days)
Show older comments
I have several CSV files.
After processing each CSV file, I want to save each CSV file to other name using for loop.
The names of input file are different (bend1.csv, walk2.csv, jogging2.csv, ....)
X = csvread('bend1.csv');
X = X(:,1:28);
data = X';
% After processing......
% I want to each Y matrix to CSV files
Y = Phi_NuMax * X';
a simple structure:
outDir = yourDestination.
allCsvFiles = dir(fullfile(yourDirectory, '.*csv'));
for iA = 1:length(allCsvFiles)
curFile = allCsvFiles(iA).name;
yourTable = readtable(fullfile(yourDirectory, curFile));
% your process
writetable(fullfile(outDir, curFile), yourTable);
More Answers (0)
Find more on Debugging and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!