How to append data to writetable file?
11 ビュー (過去 30 日間)
古いコメントを表示
I have a UI that I am making for a project. The sponsors of the project require that the data input into the UI be saved to excel and as a csv. The UI has both text and numerical values, and the only way I have found to successfully export the data to a csv is with writetable, but I can't find a way to append new data to the end of it. Any help or advice?
3 件のコメント
winkmal
2019 年 9 月 26 日
I have a similar problem. I read a CSV file with readtable, append some values to the table, and then write it back to CSV for later usage with writetable. But I want to make sure that in this process, no data is accidentally overwritten, so I would also like to use writetable in conjunction with an append option. Also, the first column is in datetime format, which should be correctly parsed.
With fread, instead of a simple readtable, I would need to manually write routines to have the script figure out data types and convert them correctly...
Bob Thompson
2019 年 9 月 26 日
If you are reading an entire csv file with readtable, appending values to it and then writing the entire thing back then two things are happening. 1) Technically you are overwriting all of the data that was originally in the csv file, even with data that was already there, but 2) because you have all of the original data in your table that you are writing you will not be missing any data when the file is rewritten. If you are missing data it is because of your data management in your script, not because of the read/write process.
Yes, with fread and fprintf you will need to manually specify data types, parsing, and other pieces of information, but it does allow you the fine control that it sounds like you want.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!