Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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'

Risposta accettata

Walter Roberson
Walter Roberson il 10 Giu 2015
datadir = 'C:\Users\Name\Documents\MATLAB';
d = dir(fullfile(datadir, '*.csv'));
for i=1:length(d)
filename = fullfile(datadir, d(i).name);
  5 Commenti
Stephen23
Stephen23 il 11 Giu 2015
Modificato: Stephen23 il 11 Giu 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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by