different number of delimiters error using readtable function
古いコメントを表示
I use the following code for reading text file:
fileID = fopen(full_file_name);
fclose(fileID);
tCOD=readtable(full_file_name,'FileType','text', ...
'headerlines',25,'readvariablenames',0,'MultipleDelimsAsOne', true);
The above codes work for most of the text files I read. I attached one of them (data_without_problem.txt). But some text files, I receive the following error:
Error using readtable (line 216)
Reading failed at line 121. All lines of a text file must have the same number of delimiters. Line 121 has 6 delimiters, while
preceding lines have 5.
Note: readtable detected the following parameters:
'Delimiter', '\t ', 'MultipleDelimsAsOne', true, 'Format', '%q%f%f%f%f%f'
I attached this kind of text file (data_with_problem.txt).
How I can modify the above readtable function for working with text files that different number of delimiters in all lines?
My Matlab version is 2019a.
2 件のコメント
dpb
2021 年 10 月 15 日
#dP2019 9 7 0 0 0.00000000 576 u+U IGS14 FIT GFZ
## 2069 518400.00000000 300.00000000 58733 0.0000000000000
+ 95 C01C02C03C04C05C06C07C08C09C10C11C12C13C14C16E01E02
+ E03E04E05E07E08E09E11E12E13E14E15E18E19E21E24E25E26
+ E27E30E31E33E36G01G02G03G04G05G06G07G08G09G10G11G12
+ G13G14G15G16G17G18G19G20G21G22G23G24G25G26G27G28G29
+ G30G31G32J02J03J07R01R02R03R05R07R08R09R11R12R13R14
+ R15R16R17R18R19R20R21R22R23R24 00 00 00 00 00 00 00
++ 10 10 10 10 10 6 8 6 6 8 10 8 8 6 6 6 6
++ 6 6 8 6 6 6 6 6 6 6 6 6 6 6 6 6 6
++ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
++ 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
++ 6 6 6 6 6 8 10 6 8 8 8 8 6 6 6 6 6
++ 6 6 6 6 8 8 6 6 6 6 0 0 0 0 0 0 0
%c M cc GPS ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
%c cc cc ccc ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc
%f 1.2500000 1.025000000 0.00000000000 0.000000000000000
%f 0.0000000 0.000000000 0.00000000000 0.000000000000000
%i 0 0 0 0 0 0 0 0 0
%i 0 0 0 0 0 0 0 0 0
/* PCV:IGS14_2062 OL/AL:FES2004 NONE YN CLK:CoN ORB:CoN
/* GeoForschungsZentrum Potsdam
/*
/*
* 2019 9 7 0 0 0.00000000
PC01 -32247.666769 27128.253711 852.734449 -142.854736
PC02 4291.889841 41959.462941 -227.014442 886.812431
PC03 -14756.270737 39468.969011 529.367042 -15.526662
PC04 -39608.430012 14398.971601 684.035369 -18.784543
...
is the beginning of the so-called "problem" file -- what do expect to be able to read from it?
It clearly has header information and different kinds of data in it; a "one size fits all" solution is unlikely to be possible unless you can just skip the header and read the regular data after the header information.
sermet OGUTCU
2021 年 10 月 15 日
編集済み: sermet OGUTCU
2021 年 10 月 15 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!