フィルターのクリア

How to load multiple csv files and save them after converting into arff files?

2 ビュー (過去 30 日間)
hello_world
hello_world 2015 年 6 月 10 日
編集済み: hello_world 2015 年 6 月 12 日
Hello Friends,
I have several csv files, all stored in path 'C:\Users\Name\Documents\MATLAB\*.csv'. I want to loop one by one each file in order, convert them into arff files, and save them 'C:\Users\Name\Documents\MATLAB\*.arff'

採用された回答

Walter Roberson
Walter Roberson 2015 年 6 月 10 日
datadir = 'C:\Users\Name\Documents\MATLAB';
d = dir(fullfile(datadir, '*.csv'));
for i=1:length(d)
filename = fullfile(datadir, d(i).name);
  5 件のコメント
Stephen23
Stephen23 2015 年 6 月 11 日
編集済み: Stephen23 2015 年 6 月 11 日
It would be much more robust to use regexprep rather than indexing and string concatenation, something like this:
>> name = 'MyFile.csv';
>> regexprep(name,'\.csv$','.arff')
ans =
MyFile.arff
Walter Roberson
Walter Roberson 2015 年 6 月 11 日
outfile = [filename(1:end-3) 'arff'];

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by