readtable bug with tab delimiter and commas within a field.

조회 수: 18 (최근 30일)
cmo
cmo 2015년 9월 17일
댓글: Peter Perkins 2015년 9월 21일
Consider a tab-delimited text file, in which a given field may contain a string with commas, e.g.
......
A<tab>B<tab>C,D,E<tab>F
.......
Matlab's "readtable" function with delimiter=\t will parse the third field ("C,D,E") into multiple lines, rather than treating it as one field.
That is, the command:
readtable( filename, 'FileType', 'text', 'Delimiter', '\t', 'ReadRowNames', 0 , 'ReadVariableNames', 0)
will NOT return a table with the 3rd column/Variable having value "C,D,E" but rather split that field into multiple lines/entries (very strange).
  댓글 수: 3
Chris Turnes
Chris Turnes 2015년 9월 18일
Can you post a small portion of your file that can reproduce the issue? I wasn't able to reproduce with a file that was:
A<tab>B<tab>C,D,E<newline>
F<tab>G<tab>H,I,J
You might also want to try specifying the 'Format' parameter and see if that helps.
Peter Perkins
Peter Perkins 2015년 9월 21일
cmo, I can't reproduce this in any version of MATLAB since R2013b. You haven't said what version or platform you're running on.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by