How to convert csv file to .dat file?
171 次查看(过去 30 天)
显示 更早的评论
I want to read a csv file and save it as .dat file without the commas. How can I do so?
0 个评论
采纳的回答
Voss
2022-3-18
编辑:Voss
2022-3-18
% read the csv file:
data = readmatrix('data.csv')
% write the data to .dat file using
% space as the delimiter (no commas):
writematrix(data,'data.dat','Delimiter',' ');
% check that the .dat file looks right:
fid = fopen('data.dat');
dat_data = fread(fid,'*char').';
fclose(fid);
disp(dat_data); % looks good
I assumed the .csv file contains just numbers. If that's not the case, then you'd have to use functions other than readmatrix() and writematrix().
6 个评论
Mateusz
2023-3-24
Hi! How should I edit your script in order to modify multiple files file_00XXX.csv to dat files?
Thank you in advance!
更多回答(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!