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
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
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 个)

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by