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

2 vues (au cours des 30 derniers jours)
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'

Réponse acceptée

Walter Roberson
Walter Roberson le 10 Juin 2015
datadir = 'C:\Users\Name\Documents\MATLAB';
d = dir(fullfile(datadir, '*.csv'));
for i=1:length(d)
filename = fullfile(datadir, d(i).name);
  5 commentaires
Stephen23
Stephen23 le 11 Juin 2015
Modifié(e) : Stephen23 le 11 Juin 2015
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 le 11 Juin 2015
outfile = [filename(1:end-3) 'arff'];

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur App Building dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by