File Exchange

image thumbnail

EZread

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

2 Downloads

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 (2020). EZread (https://www.mathworks.com/matlabcentral/fileexchange/11026-ezread), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (15)

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

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

Cheol Hee

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

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

i=1;
while (i<1000)
i=i+1
a=ezread('c:\temp\test.txt','\t');
end

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

JON AM

GOOD PROGRAM

Sean Wilson

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

Updates

1.0.0.0

Changed %s to %q to handle strings within double quotes that have a comma within them

Included reference to related "ezwrite" function in description

Updated file

Updated description to better describe the functionality of the file

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