RunMat
GitHub

importdata — Import numeric text data with optional headers.

A = importdata(filename) imports legacy numeric text files, returning either a numeric matrix or a structure containing imported data plus header metadata.

Syntax

A = importdata(filename)
A = importdata(filename, delimiterIn)
A = importdata(filename, delimiterIn, headerlinesIn)

Inputs

NameTypeRequiredDefaultDescription
filenameStringScalarYesFile to import.
delimiterInStringScalarNoDelimiter to use for text files.
headerlinesInIntegerScalarNoNumber of header lines to skip.

Returns

NameTypeDescription
AAnyImported numeric matrix or import structure.

Errors

IdentifierWhenMessage
RunMat:importdata:InvalidArgumentFilename, delimiter, or header line arguments are malformed.importdata: invalid argument
RunMat:importdata:IoThe input file cannot be read.importdata: unable to read file
RunMat:importdata:ParseText content cannot be imported as supported numeric/header data.importdata: unable to parse text data

How importdata works

  • Supports importdata(filename), importdata(filename, delimiterIn), and importdata(filename, delimiterIn, headerlinesIn).
  • Automatically detects comma, tab, semicolon, pipe, or whitespace delimiters from non-empty lines when no delimiter is supplied.
  • Pure numeric files return a double tensor directly, matching MATLAB's convenient legacy behavior.
  • Files with header rows return a struct with data, textdata, and, when inferable, colheaders.
  • Files with leading row labels return a struct with rowheaders and numeric data.
  • Recognizes NaN, Inf, +Inf, and -Inf; empty numeric fields import as NaN.
  • Unsupported mixed text/numeric rows produce a descriptive parse error. Binary/image/audio/MAT import expansion should be handled by the dedicated import builtins as those domains mature.

Does RunMat run importdata on the GPU?

importdata does not launch provider kernels or participate in fusion.

GPU memory and residency

importdata is a host file-I/O source. It returns host tensors or structs and does not create GPU-resident arrays.

Examples

Import a plain numeric text matrix

A = importdata("values.txt")

Import CSV data with a header row

S = importdata("run.csv");
S.colheaders
S.data

Specify delimiter and header-line count

S = importdata("log.dat", '|', 2)

Using importdata with coding agents

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

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

FAQ

When does importdata return a struct?

It returns a struct when header text, column headers, or row headers are present. Pure numeric files return a tensor.

How does delimiter detection work?

RunMat samples non-empty lines and chooses a consistent comma, tab, semicolon, or pipe delimiter; otherwise it falls back to whitespace splitting.

Does this replace readmatrix?

No. importdata preserves MATLAB's legacy convenience behavior. Prefer readmatrix or readtable for new code that needs explicit import options.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how importdata 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.