Adding a string in front of every variable in a table

I was looking to make a script that added a string in front of every variable in my table.
For example, I want to add "Table_" in front of every variable in the table I've attached to this post.

 Respuesta aceptada

Voss
Voss el 20 de Sept. de 2022
% read the table
t = readtable('Ztable.xlsx','VariableNamingRule','preserve');
% modify the variable names
t.Properties.VariableNames = strcat('Table_',t.Properties.VariableNames);
% save the table
writetable(t,'Ztable_modified.xlsx')

2 comentarios

BA
BA el 20 de Sept. de 2022
Thank you!
Or using the string data type...
t.Properties.VariableNames = "Table_" + t.Properties.VariableNames;

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2022a

Etiquetas

Preguntada:

BA
el 20 de Sept. de 2022

Comentada:

el 21 de Sept. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by