Azzera filtri
Azzera filtri

Cell/table Reformat

1 visualizzazione (ultimi 30 giorni)
Koen Nijssen
Koen Nijssen il 13 Giu 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.

Risposta accettata

Pavithra Ashok Kumar
Pavithra Ashok Kumar il 15 Giu 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.

Più risposte (0)

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by