How to read CSV file and save the result to another CSV file
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello.
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, ....)
clear all
close all
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';
csvwrite('/result/bend1.csv', Y);
댓글 수: 2
Akira Agata
2020년 3월 26일
편집: Akira Agata
2020년 3월 26일
You mean, you have many CSV files in one folder and want to save in another folder with the same file name after applying some processing?
채택된 답변
Peng Li
2020년 3월 26일
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);
end
댓글 수: 6
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!