I cant append tables from a workspace variable to a file
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Jan
2017 年 8 月 11 日
編集済み: Jan
2017 年 8 月 11 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で String Parsing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!