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!