Effacer les filtres
Effacer les filtres

Cell/table Reformat

1 vue (au cours des 30 derniers jours)
Koen Nijssen
Koen Nijssen le 13 Juin 2016
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.

Réponse acceptée

Pavithra Ashok Kumar
Pavithra Ashok Kumar le 15 Juin 2016
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.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by