Splitting columns of a table

3 次查看(过去 30 天)
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
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by