Skip to content

readtable

io · scripts/io/readtable.m

READTABLE  Read a table from a delimited text file (MATLAB compat).

 This used to read the file with readmatrix () and wrap the result in
 array2table (), which meant it could only ever return numbers: any file
 with text columns came back as NaN.  It also ignored 'ReadRowNames', and
 array2table () hands back a struct-backed table, so the result had no
 usable Properties.RowNames either.

 Real case: MTEX keeps its sample-data catalogue in data/summary.txt --
 three text columns, whitespace separated -- and reads it with
   readtable (..., 'ReadRowNames', true)
 then looks datasets up by row name.  mtexdata () therefore reported
 "data not found" for every dataset, which is the first thing all ten
 ORTools examples do.

 The result is built with nexus_table_struct (), the same struct-backed
 representation array2table () produces, because that is the one the
 interpreter routes table indexing to: chained access such as
 tbl(name,:).var works on it, while on the classdef table it fails with
 "wrong type argument 'object'".