Cell/table Reformat

3 次查看(过去 30 天)
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
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 CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by