When using Matlab readtable(...)
(link) the function flexibly finds the best fitting field format (text, number) for each column:
tbl = readtable(filename);
one can specify to import dates as text as follows:
tbl = readtable(fileName,'DateTimeType','text');
However, since I am working with mixed data, I want to surpress that Matlab automatically sets their own format.
How can I import everything as text?
Note: I know that you can add 'Format', '%s %s ...'
, but I do not wish to use this option as it requires knowing the number of columns beforehand (which I do not know)
You should be able to do this using detectImportOptions
and setvartype
as follows:
opts = detectImportOptions(fileName);
opts = setvartype(opts, 'char');
tbl = readtable(fileName, opts, 'DatetimeType', 'text');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With