Write/Read CSV file
8 次查看(过去 30 天)
显示 更早的评论
I'm trying to write table into a CSV file that looks like the following:
Row 1 will be kept the same, then the other rows will be added to the file while the script is running (or added at once at the end).
I tried using writetable, csvwrite, etc... but it does not come out to what I want, and I am having trouble creating a matrix with text.
Please help. Thanks.
2 个评论
Geoff Hayes
2019-7-2
Peng - please clarify what you mean by but it does not come out to what I want. Does something get written to file? Is some data overwritten by other data? What code have you written?
回答(2 个)
Chirag Nighut
2019-7-2
To create a matrix with text you can create a 2D array of chars. To do that you can use the following code:
data = ['MATLAB ';'SIMULINK ';'POLYSPACE'];
celldata = cellstr(data)
chr = char(celldata)
Although before using char you should check if celldata is cell array of character vetors. Following function can help you
iscellstr
I request you to post the exact error/difficulty that you got using csvwrite and writetable. I can then try to help you get the desired results.
Kaustav Bhattacharya
2019-7-2
Look at the append data section of this link. https://in.mathworks.com/help/matlab/ref/dlmwrite.html
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!