readtable() custom variable names
147 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Muhammed Yusuf Aksel
le 4 Avr 2020
Commenté : Stephen23
le 18 Mai 2022
I am using the below command to read a csv file into a table called T.
T = readtable("library.csv")
Now, the first row of the csv inludes the column headers, or variable names you can say. However, I want to change those variable names as I want. I have inspected readtable() documentation, but could not find the solution.
How can I do this?
Thanks.
0 commentaires
Réponse acceptée
Ameer Hamza
le 4 Avr 2020
Modifié(e) : Ameer Hamza
le 4 Avr 2020
One way is to change the variable names after reading the file like this.
t = readtable("library.csv");
t.Properties.VariableNames = {'name1', 'name2'}; % names of columns
6 commentaires
Walter Roberson
le 18 Mai 2022
table() objects must have unique names for each variable. It is not possible to create a table() object which does not have variable names.
You can readtable() and pass VariableNames at the time of reading, thereby giving some name of your choice.
You can skip a header by using HeaderLines, 1 and ReadVariableNames, false
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Text Files 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!