フィルターのクリア

Splitting columns of a table

5 ビュー (過去 30 日間)
Sonali
Sonali 2024 年 5 月 11 日
コメント済み: Sonali 2024 年 5 月 12 日
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);
  1 件のコメント
Sonali
Sonali 2024 年 5 月 12 日
Thanks Walter.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by