How to remove all weird column names from a table and replace them (with numbers or alphabet letters)?

29 vues (au cours des 30 derniers jours)
I have a file in the .csv format.
When I transfer it to Matlab, the column names turn into some kind of gibberish.
In fact, I need to remove all these names and replace them with anything (numbers or letters of the alphabet in ascending order).
The problem is, how to remove all the column names at once without manually entering them in the removevars command?

Réponse acceptée

KSSV
KSSV le 24 Oct 2024 à 5:06
Modifié(e) : KSSV le 24 Oct 2024 à 5:07
T = readtable(myfile) ;
T.Properties.VariableNames = {'1','2','3','4','5','6','7','8'} ;
NOTE: The column names on the right should be of same size of number of columns.
Also give a try on:
T = readtable(myfile,'VariableNamingRule','preserve')
  1 commentaire
Andrew Sol
Andrew Sol le 24 Oct 2024 à 6:28
The second option didn't work as expected.
But with the help of your first option (and my addition) it worked.
T = readtable(myfile.csv);
number_of_column = string(1:size(T,2));
T.Properties.VariableNames = number_of_column;

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by