I am running something like this:
table = readtable(path,'ReadVariableNames',true);
In the .csv file all of the cells of the first row contain string identifiers like '99BM'
, '105CL'
, etc. Everything starts with a number. The command above gives a table with variable names like 'x99BM'
, 'x105CL'
, etc.
Is it possible to get rid of this 'x'
? I need to compare these identifiers with a column of another table that is clear of this 'x'
.
No, table variable names can't start with a number since they follow the same naming conventions as normal variables. The
'x'
is automatically added byreadtable
to create a valid name. You should have noticed this warning when callingreadtable
:So, you can't get rid of the
'x'
within the table. But, if you need to do any comparisons, you can do them against the original values saved in theVariableDescriptions
property, which will have this format:You can parse these with a regular expression, for example:
And then use these in any string comparisons you need to do.