I'm importing data using the loop below. I'm getting an error that some of the table variables cannot be concatenated because they're a cell in one table and a noncell in another. How an I correct this? The reason for this issue is because in some data files the variable has actual values and for some parts of the files, the data appears as an NaN. Any help would be appreciated
FileID = dir('*.dat');
T = table;
for j=1:length(FileID)
opts = detectImportOptions(FileID(j).name);
Ts = readtable(FileID(j).name,opts,'ReadVariableNames',false);
Ts.Properties.VariableNames=VarNames;
T = [T;Ts];
end

 채택된 답변

Walter Roberson
Walter Roberson 2018년 12월 3일

0 개 추천

Do the detection once against a file that has numeric in that column and use those options for all of the files.
Alternatively after the option detection bash the setting for that column to make the variable numeric with the appropriate nan detection .

댓글 수: 3

Susan Santiago
Susan Santiago 2018년 12월 4일
can you give me an idea of how this would actually look in the code? I'm struggling because I think I don't 100% know how these functions work.
Susan Santiago
Susan Santiago 2018년 12월 4일
Actually I figured it out! I used setvartype in case anyone wants to know. Thanks for the answer
FileID = dir('*.dat');
T = table;
opts = detectImportOptions(FileID(1).name);
for j=1:length(FileID)
Ts = readtable(FileID(j).name,opts,'ReadVariableNames',false);
Ts.Properties.VariableNames=VarNames;
T = [T;Ts];
end

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by