I cant append tables from a workspace variable to a file
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Jan
il 11 Ago 2017
Modificato: Jan
il 11 Ago 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 Commenti
Vedere anche
Categorie
Scopri di più su String Parsing 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!