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

1 visualización (últimos 30 días)
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'

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by