필터 지우기
필터 지우기

I need to add a hash (#) at the first position of a text file which is created by writetable. Rename of VariableNames does not work.

조회 수: 2 (최근 30일)
I created a table with two columns and derived a tab-delimited txt-file. I Need to add a hash (#) at the very first Position of the txt-file. Thought about renaming the table.properties but doesn´t with #. Any tips?

채택된 답변

BA
BA 2017년 4월 26일
Solved on my own.
  1. Create temporay text files containing the hash (#)
  2. Merge temporay file and data file
  3. Delete temporary file.
hash='#';
hashtxt=fopen('Hash.txt', 'w+');
fprintf(hashtxt, hash);
fclose(hashtxt);
system('copy/b Hash.txt+datafile.txt finalfile.txt');
delete Hash.txt;
delete datafile.txt;
Link to copy/b
"If it looks stupid but it works it ain´t stupid"

추가 답변 (1개)

Fei Deng
Fei Deng 2017년 4월 17일
There is a similar question about adding lines to top of text files, take a look of the posted answers there. https://www.mathworks.com/matlabcentral/newsreader/view_thread/243389
"You can't put it before the original first character of the file, as that could result in overwriting the tail part of another file. You can't create new locations on the disk (at least not without deforming the disk and transforming a lot of energy into matter to create the new disk material.)"

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by