Readtable gives unusual results reading data from a text file.
Show older comments
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 Comments
Geoff Hayes
on 4 Apr 2022
@dormant - can you attach the data file?
Jan
on 4 Apr 2022
If you post the file, we can check search for the problem also.
Stephen23
on 4 Apr 2022
"Any suggestions?"
The files are different. Click the paperclip button to upload some sample files for us to look at.
dormant
on 4 Apr 2022
Accepted Answer
More Answers (0)
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!