필터 지우기
필터 지우기

concatenating with readtable function

조회 수: 7 (최근 30일)
Daniel Abraham
Daniel Abraham 2021년 7월 19일
댓글: KSSV 2021년 7월 19일
Hello Everyone. Please I'm trying to readtables from a multiple xml files in a loop. Each xml file holds data for a time period.
Using the code below reads each xml file as a table
table1: readtable('filename.xml')
but I want to read all the xml files in the folder at once as a table so I can get to see all data at once. When I try to read random xml files as tables. It seems most have the same amount variables but some differ. I think for me, it's okay if the code can skip these files.
Thank you so much

채택된 답변

KSSV
KSSV 2021년 7월 19일
xmlFiles = dir('*.xml') ;
N = length(xmlFiles) ;
T = cell(N,1) ;
for i = 1:N
T{i} = readtable(xmlFiles(i).name) ;
end
celldisp(T)
  댓글 수: 2
Daniel Abraham
Daniel Abraham 2021년 7월 19일
Thanks KSSV, it puts all the tables in a cell. That helps a lot!
Quick follow up, how does one concatenate all the simlar tables (similar variable names) in the cell as one table?
KSSV
KSSV 2021년 7월 19일
If the varable names are same and T1, T2 can be joined:
T12 = [T1; T2] ;
Also have a look on cat.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by