필터 지우기
필터 지우기

Reading file with pilcrow (paragraph) sign

조회 수: 2 (최근 30일)
Sergio Vez
Sergio Vez 2019년 10월 29일
댓글: Sergio Vez 2019년 10월 29일
I need to read a file with rows like this
calculation.update.date=09.10.2019¶
I'm textscanning the ".txt" into 2 column matrix (one with "calculation.update.date" and the other one with "09.10.2019¶")
To do that I used
opt = {'Delimiter','='};
data_type = '%s%[^\n]';
fileID = fopen('ENTRADA.txt','rt');
C_aux = textscan(fileID,data_type,opt{:},'CollectOutput',1);
I would like to do the same but getting "09.10.2019" in the second column instead of "09.10.2019¶"
I would also like to be able to include a at the end of each row when finishing the program, in order to export it in a proper way.
How could I do it?
Thanks in advanced!
Sergio

채택된 답변

Stephan
Stephan 2019년 10월 29일
편집: Stephan 2019년 10월 29일
This should help:
>> A = '09.10.2019¶'
A =
'09.10.2019¶'
>> A(end) = []
A =
'09.10.2019'
also maybe helpful:
>> a = '¶'
a =
'¶'
>> double(a)
ans =
182
also note:
>> A = "09.10.2019¶" % String instead of char!
A =
"09.10.2019¶"
>> whos A
Name Size Bytes Class Attributes
A 1x1 166 string
>> A(end) = [] % This doesnt work!
A =
1×0 empty string array
>> A = char(A)
A =
'09.10.2019¶'
>> whos A
Name Size Bytes Class Attributes
A 1x11 22 char
>> A(end) = []
A =
'09.10.2019'
  댓글 수: 9
Stephan
Stephan 2019년 10월 29일
I missunderstood you... sorry - see attached file
Sergio Vez
Sergio Vez 2019년 10월 29일
Thanks!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by