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.

 採用された回答

Voss
Voss 2022 年 9 月 20 日

0 投票

% 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 件のコメント

BA
BA 2022 年 9 月 20 日
Thank you!
Eric Sofen
Eric Sofen 2022 年 9 月 21 日
Or using the string data type...
t.Properties.VariableNames = "Table_" + t.Properties.VariableNames;

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

製品

リリース

R2022a

質問済み:

BA
2022 年 9 月 20 日

コメント済み:

2022 年 9 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by