I cant append tables from a workspace variable to a file
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have a workspace variable containing for example 5 rows, 2 columns, each cell carrying another array of 4 rows, 1 column.
I want to write each cell into 1 column in a csv file, but no matter what I do, it is only taking the last iteration (like it overwrote the data for each iteration or something). Do you have any ideas?
I have also tried fprintf, csvwrite..., but it gave terrible error messages like java..... something
Here is my code for that part:
for i = 1 : 5
fileout = fopen ('the_extracted_data.csv','a+');
outtable = table (data{i}, data {i,2});
writetable (outtable,'the_extracted_data.csv');
fclose (fileout);
end
Thanks in advance!
0 commentaires
Réponses (1)
Jan
le 11 Août 2017
Modifié(e) : Jan
le 11 Août 2017
writetable overwrites the formerly existing files. Using fopen and writetable interfere with each other.
What about:
outtable = table(data(1:5,1), data(1:5,2));
writetable(outtable, 'the_extracted_data.csv');
I did not understand, what the contents of your data are, so perhaps you have to adjust this. Posting some code which produces a small example might be more useful.
0 commentaires
Voir également
Catégories
En savoir plus sur String Parsing 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!