How can I write to a CSV file in separated columns and without any commas?
32 ビュー (過去 30 日間)
古いコメントを表示
I am using the following code to write in a CSV file for 10 different columns but I end up with all data in a single column and commas between each data.
dlmwrite('/Users/.../matlabdandata2.csv',[frames' time' cycle' ...],'delimiter',',','-append')
Thanks!
0 件のコメント
回答 (3 件)
Christopher Wallace
2018 年 7 月 13 日
編集済み: Christopher Wallace
2018 年 7 月 13 日
csvwrite('matlabdandata2.csv', [frames, time, cycle])
9 件のコメント
Walter Roberson
2018 年 7 月 14 日
Image Analyst
2018 年 7 月 14 日
編集済み: Image Analyst
2018 年 7 月 14 日
That workbook has only 5 columns and they don't even have names that match. How are we supposed to generate the variables he called "[frames' time' cycle' ...]" which he is trying to stitch together?
And does he want 3 columns in the output text file, or 10 columns? And what does "the only problem is separating as 10 different columns" mean?
Image Analyst
2018 年 7 月 13 日
When you did this:
dlmwrite('/Users/.../matlabdandata2.csv', [frames' time' cycle' ...], 'delimiter', ',', '-append')
did you notice that you specified a comma as the delimiter? Why?
If you don't want a comma, specify a space or something else as the delimiter.
2 件のコメント
Image Analyst
2018 年 7 月 13 日
What does this say in the command window:
data = [frames', time', cycle', ...etc....] % Stitch 10 vectors side by side.
whos data
dimensions = size(data)
Attach your data if you want people to help you.
Ece Su Ildiz
2018 年 7 月 14 日
6 件のコメント
Image Analyst
2018 年 7 月 14 日
When you said "separator" regarding a CSV (Comma Separated Variable) file I assumed you meant the separator between the complete numbers. Now I'm wondering if you're talking about the separator between the thousands and millions groups in the number instead. Which is it?
Also I'm wondering if the columns in your table are actually strings, because I don't see why, in your first screenshot, cell F1 uses a comma but cell F2 uses a period for the decimal point.
What is your "region" (country) that your computer is set up for in your settings/control panel? Is it one of those countries that uses commas instead of dots for decimal points?
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!