MATLAB Answers

0

Readtable() confused by quotation marks? Matlab 2019a

Michael 님이 질문을 제출함. 26 Aug 2019
최근 활동 Michael 님이 답변함. 26 Aug 2019
Hello.
When executing
t = readtable('myfile.txt','FileType','text','Delimiter','|');
I am receiving this error
Error using readtable (line 216)
Reading failed at line 52223. All lines of a text
file must have the same number of delimiters. Line
52223 has 5 delimiters, while preceding lines have 9.
Note: readtable detected the following parameters:
'HeaderLines', 0, 'ReadVariableNames', false,
'Format', '%f%q%f%f%f%q%q%f%f%f'
I confirmed that the error is thrown, not because of the delimiters but because of a quotation mark. I confirmed this by removing the quotation marks from the file. Is there a way around this without altering the file itself?
Thank You,
Michael

  댓글 수: 1

Could you attatch the text file?

로그인 to comment.

답변 수: 2

Answer by Jeremy Hughes on 26 Aug 2019
 Accepted Answer

opts = detectImportOptions('myfile.txt','FileType','text','Delimiter','|')
T = readtable('myfile.txt',opts)

  댓글 수: 0

로그인 to comment.


Answer by Michael on 26 Aug 2019

That worked. Thanks.

  댓글 수: 0

로그인 to comment.



Translated by