How to append data to writetable file?
조회 수: 13 (최근 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!