필터 지우기
필터 지우기

Writing cells to text file without double quotes

조회 수: 54 (최근 30일)
M Teaxdriv
M Teaxdriv 2022년 5월 26일
댓글: M Teaxdriv 2022년 5월 26일
Hello guys,
I am trying to write cell vector to text file using fprintf - this does not work because it requires some formatting but I want to write it just "like it is" in the cells. Next I am trying writecell command - this works but it adds double quote at the beginning of each line in the text file what is super annoying.
The cells look like shown below:
After command writecell final text file looks like:
"/batch
"
"/config,noeldb,1 ! force off writing results to database
"
"*get,_wallstrt,active,,time,wall
but, of course, it should look like this in the written text file:
/batch
/config,noeldb,1 ! force off writing results to database
*get,_wallstrt,active,,time,wall
UPDATE: After using QuoteStrings set to false there are no quotation marks, but still there empty lines between each string. Do you have idea how to remove them?
Therefore I would like to ask you for help.
Best regards
Michal
  댓글 수: 2
Stephen23
Stephen23 2022년 5월 26일
편집: Stephen23 2022년 5월 26일
" but it adds double quote at the beginning of each line in the text file..."
No it doesn't, it actually adds double quotes around your text. There is a difference.
"but still there empty lines between each string."
Because each of your character vectors ends with some kind of newline character.
"Do you have idea how to remove them?"
Remove the newline characters from the cell array, e.g. STRTRIM or DEBLANK or REGEXPREP.
M Teaxdriv
M Teaxdriv 2022년 5월 26일
Hello Stephen23,
thank you for explanation!
Michal

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

채택된 답변

Walter Roberson
Walter Roberson 2022년 5월 26일
fprintf(fid, "%s\n", YourCell{:})

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by