Readtable gives unusual results reading data from a text file.
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Stephen23
le 4 Avr 2022
T = readtable('20160419-2010.txt','NumHeaderLines',0)
T = readtable('20111118-0021.txt','NumHeaderLines',0)
T = readtable('20080505-0553.txt','NumHeaderLines',0)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!