readtable error after r2014a --> r2022b upgrade

I have a script coded in MATLAB R2014a, running correctly. After intalling R2022b or later this line
t = readtable('test.txt', 'Delimiter',';');
results in error:
Delimiter must be a string array, character vector, or cell array of character vectors.
Why?
(t=readtable('test.txt') also causes this error.)

1 Comment

It seems likely to me that you have some third-party function with the same name as a Mathworks function, and that third-party function is interfering with parsing the delimiter.
Unfortunately after a bunch of tracing, I do not see where in the internal code that the validity of the delimiter is tested, so I am not presently able to guess as to which third-party function might be involved.
I suggest to copy the data file into a new directory, and try the readtable() from that new directory; if it works then the problem is a third-party function in you previous current directory. If it does not work, then I would suggest experimenting with
restoredefaultpath; rehash toolboxcache
and seeing whether the readtable() works; if it does then the problem is with some third-party toolbox that you had on your path.

Sign in to comment.

Answers (1)

Try one of these —
t = readtable('test.txt', 'Delimiter',";");
or:
t = readtable('test.txt', 'Delimiter',{';'});
The only illustrations in the 2024b documentation use string, " " arrays, although creatiing a cell array (by enclosing the value in curly brackets {}) could also work.

2 Comments

I've tried before.
t = readtable('test.txt') results in same error.
It runs here without error —
T1 = array2table(randi(9,5,3))
T1 = 5x3 table
Var1 Var2 Var3 ____ ____ ____ 8 8 3 8 8 7 6 2 4 8 7 2 3 8 3
writetable(T1, 'test.txt', 'Delimiter',';')
type('test.txt')
Var1;Var2;Var3 8;8;3 8;8;7 6;2;4 8;7;2 3;8;3
t = readtable('test.txt', 'Delimiter',';');
disp(t)
Var1 Var2 Var3 ____ ____ ____ 8 8 3 8 8 7 6 2 4 8 7 2 3 8 3
I seriously doubt that this is an inherent problem with R2022b itself, although your installation may be having problems.
You may need to Contact Support.
.

Sign in to comment.

Categories

Products

Release

R2022b

Asked:

on 7 Jan 2025

Commented:

on 7 Jan 2025

Community Treasure Hunt

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

Start Hunting!