Cell/table Reformat

2 ビュー (過去 30 日間)
Koen Nijssen
Koen Nijssen 2016 年 6 月 13 日
回答済み: Pavithra Ashok Kumar 2016 年 6 月 15 日
I have a very specific formatting issue. Right now, I have used the readtable command to load a csv file into the workspace. It looks something like this:
A={'Country', 'Prod1', 'Prod2';
'BE', '5', '8';
'NL', '15', '9';
'DE','13','18'};
However, I need it to look like this:
A={'Country','Product #', 'Amount';
'BE', '1', '5';
'BE', '2', '8';
'NL', '1', '15';
'NL', '2', '9'; ...}
Thanks for the help.

採用された回答

Pavithra Ashok Kumar
Pavithra Ashok Kumar 2016 年 6 月 15 日
Hi
The "readtable" treats the entries in the first line of the file as variable names. So updating the first line of your .dat file should solve the issue. You can programmatically change the variable names by :
T.Properties.VariableNames{'Prod1'} = 'Product #';
Hope this helps.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by