I'm confused about how to determine the delimiter between columns for data like this
조회 수: 12 (최근 30일)
이전 댓글 표시
Hello, Community
I have a simple question but it was actually difficult to me. So i have data like this :
To extract the above data column by column, I used the readtable function with the detectImportOptions like this :
cek_web_kyoto_quicklook = detectImportOptions(pathfile_web_kyoto_quicklook{bul_quicklook},'ReadVariableNames',false, 'Delimiter', " ", 'EmptyFieldRule', 'missing', 'EmptyLineRule', 'skip',...
'Whitespace', {'\b\t ',''}, 'FileType','text',...
'ConsecutiveDelimitersRule', 'join');
cek_web_kyoto_quicklook.VariableTypes = {'string', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double'};
cek_web_kyoto_quicklook.VariableNames = {'waktu', 'baseval', 'dst1', 'dst2', 'dst3', 'dst4', 'dst5', 'dst6', 'dst7', 'dst8', 'dst9', 'dst10', 'dst11', 'dst12', 'dst13', 'dst14', 'dst15', 'dst16', 'dst17', 'dst18', 'dst19', 'dst20', 'dst21', 'dst22', 'dst23', 'dst24', 'mean_dst'};
Tabel_Web_kyoto_quicklook0 = readtable(pathfile_web_kyoto_quicklook, cek_web_kyoto_quicklook);
Nan_tabeldst_quicklook = standardizeMissing(Tabel_Web_kyoto_quicklook0(:,2:end), {9999});
Tabel_Web_kyoto_quicklook0(:,2:end) = Nan_tabeldst_quicklook;
Tabel_Web_kyoto_quicklook = Tabel_Web_kyoto_quicklook0(1:end-1,:);
However, i dont know how to fix one of nargin inside of the detectImportOptions function, specifically " Delimiter ". I just set the Delimiter with ' ', and the result becomes like this :
From the above result in command window, numbers without separated by spaces (-127-120-120-128-124-112-112-112-110-120-117) will be NaN data, but numbers separated by spaces (-96 -88 -80 -76 -71 -75 -78 -73) will still be correct data.
The question is: How to make the data that is not separated by spaces (-127-120-120-128-124-112-112-110-120-117) can still be extracted/retrieved into complete data, which is as follows: -127 -120 -120 -128 -124 -112 -112 -112 -110 -120 -117
Any answer will be very helpful to me in finding this solution, for example by using other functions other than readtable or detectImportOptions
Thus submitted a question from me, thank for your attention and cooperation
댓글 수: 1
채택된 답변
Voss
2024년 6월 20일
Use fixedWidthImportOptions, e.g.:
opts = detectImportOptions(filename,'FileType','fixedwidth'); % modify opts as necessary T = readtable(filename,opts);
or:
T = readtable(filename,'FileType','fixedwidth');
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!