Skip to content

csvread

Read a CSV file into a matrix.

M = csvread(filename)
M = csvread(filename, row, col)
M = csvread(filename, row, col, range)

Reads numeric data from a comma-separated text file. With row and col (0-based), starts reading from that offset (skips header rows). With a 4-element range = [R1, C1, R2, C2], reads only the rectangular range from (R1, C1) to (R2, C2).

File must contain only numeric values; for mixed-type CSV use readtable.

M = csvread('data.csv', 1, 0) % skip first row (header)
  • csvwrite — Write a matrix to a CSV file.
  • dlmread — Read a delimited text file into a matrix.
  • readtable — Read tabular data from a file into a table.