Readtable gives unusual results reading data from a text file.
조회 수: 4 (최근 30일)
이전 댓글 표시
I'm trying to read a lot of text files using readtable. All the files have 7 columns of data, although the last column is usually blank.
Readtable normally gives this:
39×7 table
Var1 Var2 Var3 Var4 Var5 Var6 Var7
____ ____ ____ ____ ____ ____ __________
2009 10 6 3 33 29 {0×0 char}
2009 10 6 3 36 12.3 {0×0 char}
2009 10 6 3 36 53.3 {0×0 char}
2009 10 6 3 37 6.5 {0×0 char}
...
But one text file gives a very different result:
7×1 table
x20111118015544_7RF
_________________________
{'2011 11 18 01 33 43.7'}
{'2011 11 18 01 33 51.2'}
{'2011 11 18 01 33 60.0'}
{'2011 11 18 01 35 32.3'}
{'2011 11 18 01 36 03.9'}
{'2011 11 18 01 36 25.2'}
{'2011 11 18 01 36 33.4'}
This file actually has 26 lines, but readtable only returns the last seven lines and somehow takes the table column name from the 19th line. This line has a value that should go into Var7, but so do lines in other files and they don't cause this problem.
I suspect the text file has a bad character in it, but I can't find it.
Any suggestions?
댓글 수: 5
채택된 답변
Stephen23
2022년 4월 4일
T = readtable('20160419-2010.txt','NumHeaderLines',0)
T = readtable('20111118-0021.txt','NumHeaderLines',0)
T = readtable('20080505-0553.txt','NumHeaderLines',0)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!