Splitting columns of a table
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi I have a datafile : https://drive.google.com/file/d/1pYtIqvwfjOYDzvfjeudBE5XzmXmlJFiV/view?usp=drive_link
I am trying to store it in a table using following program. It is not letting me split certain columns that have arrays as values, into different columns. Each column should have just one value. I have tried replaing the delimiter, regexp and splitvars, but they didnt work at all.
.....................................................................................................................
files = dir('mvn_lpw_l2_lpnt_20150301_v03_r02.csv');
tab = readtable(files.name)
...........................................................................
Would appreciate some help here. Thanks
댓글 수: 1
Stephen23
2024년 5월 12일
What do you expect DIR of one signle finename to achieve? Why not simply replace this:
files = dir('mvn_lpw_l2_lpnt_20150301_v03_r02.csv');
tab = readtable(files.name)
with simpler:
fnm = 'mvn_lpw_l2_lpnt_20150301_v03_r02.csv';
tab = readtable(fnm)
채택된 답변
Walter Roberson
2024년 5월 11일
files = dir('mvn_lpw_l2_lpnt_20150301_v03_r02.csv');
tab = readtable(files.name, 'Delimiter', ',', 'VariableNamingRule', 'preserve');
temp1 = regexp(regexprep(tab.(1), '[[]]', ''), '\s+', 'split');
temp4 = regexp(regexprep(tab.(4), '[[]]', ''), '\s+', 'split');
temp5 = regexp(regexprep(tab.(5), '[[]]', ''), '\s+', 'split');
c1 = cell2mat(cellfun(@str2double, temp1, 'uniform', 0));
c2 = datetime(tab.(2), 'inputformat',"uuuu-MM-dd'T'HH:mm:ss.SSS'Z'");
c3 = datetime(tab.(3), 'convertfrom', 'posixtime');
c4 = cell2mat(cellfun(@str2double, temp4, 'uniform', 0));
c5 = cell2mat(cellfun(@str2double, temp5, 'uniform', 0));
c6 = tab.(6);
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!