RunMat
GitHub

detectImportOptions — Inspect text or spreadsheet data and create import options for tabular readers.

opts = detectImportOptions(filename) samples a delimited text or spreadsheet file and returns an editable scalar struct accepted by readtable and, for numeric text imports, readmatrix.

Syntax

opts = detectImportOptions(filename)
opts = detectImportOptions(filename, nameValuePairs...)

Inputs

NameTypeRequiredDefaultDescription
filenameStringScalarYesText or spreadsheet file path to inspect.
nameValuePairsAnyVariadicDetection overrides such as Delimiter, Range, Sheet, Encoding, or TextType.

Returns

NameTypeDescription
optsAnyDetected import options struct accepted by readtable/readmatrix.

Errors

IdentifierWhenMessage
RunMat:table:InvalidArgumentArguments or table metadata are invalid.table: invalid argument
RunMat:table:InvalidIndexTable indexing is invalid.table: invalid index
RunMat:table:InvalidVariableA table variable name or value is invalid.table: invalid variable

How detectImportOptions works

  • Detects text delimiters from comma, tab, semicolon, pipe, and whitespace-separated records unless Delimiter is supplied.
  • Infers variable names from a non-data header row and sets NumHeaderLines so readers import only data rows.
  • Infers VariableTypes as double, logical, datetime, or text (string/char) using the same token rules as readtable.
  • Honors supported overrides including FileType, Delimiter, NumHeaderLines, Range, Sheet, VariableNames, VariableTypes, ReadVariableNames, ReadRowNames, TreatAsMissing, VariableNamingRule, TextType, DatetimeType, EmptyLineRule, and Encoding.
  • For spreadsheet files, uses the same sheet/range reader as readtable and emits spreadsheet-compatible option fields.
  • The returned struct intentionally contains fields understood by current RunMat readers; unsupported MATLAB option fields are not emitted.

Does RunMat run detectImportOptions on the GPU?

No acceleration provider hooks are used.

GPU memory and residency

detectImportOptions performs file inspection on the host and returns host metadata. It does not create GPU-resident arrays.

Examples

Detect And Reuse CSV Import Options

opts = detectImportOptions("measurements.csv");
T = readtable("measurements.csv", opts);

Override Detection Settings

opts = detectImportOptions("log.txt", 'Delimiter', '|', 'NumHeaderLines', 2);
opts.VariableTypes(2) = "double";
T = readtable("log.txt", opts);

Use Options With Numeric Imports

opts = detectImportOptions("values.csv");
A = readmatrix("values.csv", opts);

Using detectImportOptions with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how detectImportOptions changes the result.

Run a small detectImportOptions example, explain the result, then change one input and compare the output.

FAQ

Is the returned value a MATLAB import-options object?

RunMat represents import options as a scalar struct so field assignment and reader consumption work naturally in the current runtime.

Can I use the same options with readmatrix?

Yes for numeric text imports. readmatrix consumes fields such as Delimiter, NumHeaderLines, Range, and TreatAsMissing and ignores table-specific fields.

Does detection read the whole file?

RunMat currently reads the file into host memory and samples the parsed rows, matching the existing readtable import pipeline.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how detectImportOptions is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.