How to convert csv file to .dat file?
조회 수: 136 (최근 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!