当使用 Matlab readtable(...)
( link ) 时,该函数可以灵活地为每一列找到最合适的字段格式(文本、数字):
tbl = readtable(filename);
可以指定将日期导入为文本,如下所示:
tbl = readtable(fileName,'DateTimeType','text');
但是,由于我处理的是混合数据,所以我想禁止 Matlab 自动设置自己的格式。
如何将所有内容导入为文本?
注意:我知道您可以添加 'Format', '%s %s ...'
,但我不想使用此选项,因为它需要知道数字预先列的列(我不知道)
最佳答案
你应该能够使用 detectImportOptions
来做到这一点和 setvartype
如下:
opts = detectImportOptions(fileName);
opts = setvartype(opts, 'char');
tbl = readtable(fileName, opts, 'DatetimeType', 'text');
关于matlab - readtable - 在 Matlab 中将所有列作为文本读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45696180/