Opening and Saving files

조회 수: 1 (최근 30일)
Wei
Wei 2011년 8월 11일
Hi,
Is there a command to save files through Matlab? I have csv files (containing dates and double) and would like to save them into another folder. These files were downloaded from a data colletion software and for some reason, have quotation marks around every value, ex: A= ["3", "2008/01/02", "c31213", "0"; "5", "2008/01/05", "c36465", "1"; "6", "2008/01/54", "c31587", "4";]
this file is very hard to work with in matlab, but I noticed that once the file is resaved, the quotation marks disapear. this is why I want to resave them.
Simply opening the file and writing them into another will not work because again, reading the quotation marks is impossible.
  댓글 수: 1
Fangjun Jiang
Fangjun Jiang 2011년 8월 11일
What do you mean "resave"? Re-saved by who and how?

댓글을 달려면 로그인하십시오.

답변 (2개)

Fangjun Jiang
Fangjun Jiang 2011년 8월 11일
csvwrite() or dlmwrite()
BTW, you could easily get rid of the double quote symbol.
A='"3", "2008/01/02", "c31213"';
B=strrep(A,'"','')
You could do that too on a file with find-and-replace

Walter Roberson
Walter Roberson 2011년 8월 11일
A = fileinput(FILENAME); A(A=='"')=[]; fid = fopen(NEWFILENAME,'w'); fwrite(fid,A); fclose(fid)

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by