Borrar filtros
Borrar filtros

Splitting columns of a table

5 visualizaciones (últimos 30 días)
Sonali
Sonali el 11 de Mayo de 2024
Comentada: Sonali el 12 de Mayo de 2024
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 comentario
Stephen23
Stephen23 el 12 de Mayo de 2024
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)

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 11 de Mayo de 2024
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);

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by