File Exchange

image thumbnail


version (1.13 KB) by Paul Taylor
Easily read csv files containing both text and numeric columns


Updated 06 Sep 2007

No License

Read a CSV file that contains both text and numeric columns, without having to manually specify the column type using %f, %s, etc.

MATLAB functions such as "textscan" that can read files with columns of both text and numeric values require the user to specify the data type of each column, which can be tedious for anything but the simplest file. Instead, this function determines each column's data type automatically.

Creates a MATLAB structure from the data, with fieldnames matching the headers in the file.

See also: "ezwrite"

Cite As

Paul Taylor (2021). EZread (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (15)

Matthew Kelly

In 2012 Matlab released the function: readtable() which does nearly the same thing as ezread()

Matthew Kelly

Nice job - worked on the first try and did exactly what I wanted it to do.

Cheol Hee

Works great, read quickly than csvread!!!!!

Justin Elstrott

Works great on my mac for importing .csv files with mixed numeric and text columns from Excel! Glad I stumbled across this gem.

Joe leitten

I have a csv file, but it is only reading in the headers and the next row. nothing else is being read in?

Laura McCormack

Very nice! This is just what I needed.

Mike Smith

doesn't work even on the simplest of .cvs files

??? Error using ==> textscan
First input must be of type double.

Error in ==> ezread at 41
header_cell = textscan(header_str,'%q','delimiter',file_delim);

Error in ==> stringParsing at 5
out_struct = ezread('TEST.csv',',')

Jacob Bemrich

Exactly what I was looking for.

Ilse Van Tricht

This is right what I needed to read in a CSV file! Nice tool!!!

kevin brown

Does not take into consideration whether a text field (within quotations) has a comma in it (i.e. ...,"new york, ny",...

Aravind Ratnam

Could someone please post the 'fixed' version?

Ken Campbell

Paul contacted me shortly after my comment and has now updated the code. I'll rate it 5.

Ken Campbell

Extremely useful, but the current version doesn't close the file after opening it. This snippet crashes on my machine at about i=500

while (i<1000)

Adding fclose(fid) to the end of the file solves the problem.



Sean Wilson

Amazing! I was going to suggest that Mathworks hire the author, but it looks like they already did.

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!