save each array of a cell as sequence xls files
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello Every one,
In the code bellow, I have tried to read .csv files which were named as "Book1, Book2, Book3,..." (I have 5000 .csv as mentioned tempelate from experiments)
I just wanted to keep 4 columns and also rows which positive values.
after that I need to save each of them again as new files like "new1, new2, new3, ...."
I've got stucked on saving them cause I prepare cell to do that calculation and now I need to write each array of cell as a seperate file.
here is my code:
files = dir ('E:.......\Book*.csv')
N = length(files);
data = cell (1,N);
for i=1:N
data {i} = csvread(files(i).name);
modified {i} = data{i} (: , [1 2 4 5]);
new {i} = modified {i} (modified {i} (:,1)>0, :);
end
I will be so thankful if you can help me to now save the new{i} as seperated files with sequence.
Best Regards,
0 Commenti
Risposta accettata
Ameer Hamza
il 14 Apr 2020
Modificato: Ameer Hamza
il 14 Apr 2020
There are several functions to save data in MATLAB
The variable new {i} is probably a numeric matrix, so you can write
writematrix(new{i}, ['new' num2str(i) '.csv'])
7 Commenti
Ameer Hamza
il 14 Apr 2020
try something like this
new{i} = array2table(new{i}, 'VariableNames', {'column1', 'column2', 'column3', 'column4'}); % write name of the columns
writetable(t, ['new' num2str(i) '.csv'], 'WriteVariableNames', 1)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Structures 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!