messy table in one column
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I have a data with some strings and mostly numeric data. The strings are located in the first 11 lanes and then the numeric data is as follows ( that is the pattern until the end of the file). I just would like to get the numeric data but since the number of columns change in each line I have difficulties doing this. I tried many things (textscan, fopen, importdata etc) and I ended up using table with text option.
T1=readtable(fileName, 'FileType', 'text');
T2=T2(11:end,1);
However whatever I do I bumped into another problem and I ended up to have only one column. I can not the access the individual data since it is in the string format. I can not generate variable names neither since it is only one column. Any advice or solution is appreciated.
=== here is the one column data I ended, and I would like to save this part into another table ===
'1171 4000 24'
'4000 7 6000 2 1 12 2 2'
'-0.40695E+01 -0.27921E+01 -0.10915E+02 -0.49148E+00 -0.30083E-01 0.87037E+00 0.18997E+00 0.10000E+01 0.22955E+02'
'4000 7 1001 2 1 12 2 3'
'-0.49538E+01 -0.28463E+01 -0.93488E+01 0.12346E+00 -0.52177E+00 0.84411E+00 0.90250E-01 0.10000E+01 0.23253E+02'
Birsen
1 Kommentar
Antworten (1)
Prannay Jain
am 1 Mai 2017
To skip first 11 lines which have string, you can use,
readtable(fileName, 'HeaderLines', 11)
'readtable' expects to have the same number of columns for every row it is reading. If data is not available for some column then make it blank by providing the delimiter which you are using in your file. Providing the proper delimiter for missing values will give the expected results and convert missing values to NaN. For example,
1 45 45 2 5
4 41 56 5
34 3
will be convertrd to,
Var1 Var2 Var3 Var4 Var5
____ ____ ____ ____ ____
1 45 45 2 5
4 41 56 NaN 5
NaN 34 NaN NaN 3
0 Kommentare
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!