Effacer les filtres
Effacer les filtres

Adding a string in front of every variable in a table

3 vues (au cours des 30 derniers jours)
BA
BA le 20 Sep 2022
Commenté : Eric Sofen le 21 Sep 2022
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.

Réponse acceptée

Voss
Voss le 20 Sep 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 commentaires
BA
BA le 20 Sep 2022
Thank you!
Eric Sofen
Eric Sofen le 21 Sep 2022
Or using the string data type...
t.Properties.VariableNames = "Table_" + t.Properties.VariableNames;

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by