Adding table headers when headers change each loop

7 visualizaciones (últimos 30 días)
Natasha Bryan
Natasha Bryan el 9 de Ag. de 2021
Comentada: Peter Perkins el 9 de Ag. de 2021
Hello, I have a number of datasets that I am reading in that have varying numbers of columns (i.e. some columns are missing from some datasets). I'm attempting to process the data and then at the end of each loop adding the data to a table. My problem is that I cannot manually set the variable names of the table to {'x', 'y', 'z'} as z may not always be present. I tried using:
Headers = cell2table(originaldata.varnames);
Headers(:,contains(Headers.Properties.VariableNames, 'x'));
to create a variable 'Headers' that would change size with each loop and I could set as variable names to my final table. However using below code isn't working.
finaldata.Properties.VariableNames = {'Headers'};
%or
finaldata.Properties.VariableNames = Headers;
I do not want to have to specificy the exact variable names as they change each loop.
Is there someway to do this?
Many thanks,
Natasha
  1 comentario
Peter Perkins
Peter Perkins el 9 de Ag. de 2021
Natash, according to your description, this
finaldata.Properties.VariableNames = Headers;
should work. You need to post more information, such as what is in finaldate and Headers, and what error you are getting.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Call Python from MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by