[Reddit Cross Post] Reading XML data where commas are used as thousands and as separators
이전 댓글 표시
I need to extract the data of a lab equipment that only exports an XML file, so I'm trying to have a simple script to convert it to paired data or create a graph. The problem is: whenever the Y values go over 1000 it adds a comma separator. Using simple ',' splits won't work. What is the best approach for something like this? Why would they make it like that? ...
Hopefully it is simple to adjust (already tried the equipment side approach but can't make any modifications to the export file).
<XVALUES>6.9661,..........1.9950,1.9896,1.9845,1.9791,1.9741,1.9688,1.9632,1.9578,1.9523,1.9459,1.9376,1.9301,1.9233,1.9160,1.9086,1.9020,1.8952,1.8885,1.8820,1.8756,1.8693,1.8630,1.8569,1.8509,1.8446,1.8385,1.8327,1.8267,1.8209,1.8149</XVALUES>
<YVALUES>-10.19,.......11.17,14.56,18.45,...........,1,935.56,1,928.36,1,922.59,1,918.27,1,914.43,1,909.62,1,903.38,1,898.58,1,893.77,1,888.49,1,883.69,1,879.36,1,875.04,1,870.24,1,865.43,1,863.51,1,862.55,1,861.11,1,859.19,1,855.35,1,853.42,1,851.02,1,849.58,1,846.70,1,845.74,1,844.30,1,841.90,1,839.98,1,838.05,1,837.09,1,833.25,1,827.01,1,821.24,1,812.60,1,795.30,1,744.39,1,709.81,1,681.95,1,646.88,1,613.26,1,587.80,1,564.26,1,537.85,1,515.27,1,496.06,1,476.84,1,459.07,1,442.74,1,427.37,1,411.04,1,394.23,1,380.78,1,369.73,1,357.72,1,344.27</YVALUES>
답변 (1개)
Josh Kahn
2025년 10월 16일
편집: Walter Roberson
2025년 10월 16일
0 개 추천
data = readlines('data.xml');
yValues = cellfun(@double,regexp(data, '(?<YVALUE>\d*,?\d+.\d+)(?:,|<)', 'tokens'))
yValues =
1.0e+03 *
Columns 1 through 17
0.0102 0.0112 0.0146 0.0184 1.9356 1.9284 1.9226 1.9183 1.9144 1.9096 1.9034 1.8986 1.8938 1.8885 1.8837 1.8794 1.8750
Columns 18 through 34
1.8702 1.8654 1.8635 1.8625 1.8611 1.8592 1.8553 1.8534 1.8510 1.8496 1.8467 1.8457 1.8443 1.8419 1.8400 1.8380 1.8371
Columns 35 through 51
1.8333 1.8270 1.8212 1.8126 1.7953 1.7444 1.7098 1.6820 1.6469 1.6133 1.5878 1.5643 1.5378 1.5153 1.4961 1.4768 1.4591
Columns 52 through 59
1.4427 1.4274 1.4110 1.3942 1.3808 1.3697 1.3577 1.3443
카테고리
도움말 센터 및 File Exchange에서 Structured Data and XML Documents에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!