No BSD License  

Highlights from
EZread

4.36364

4.4 | 11 ratings Rate this file 16 Downloads (last 30 days) File Size: 2.53 KB File ID: #11026

EZread

by Paul Taylor

 

08 May 2006 (Updated 06 Sep 2007)

Easily read csv files containing both text and numeric columns

| Watch this File

File Information
Description

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"

MATLAB release MATLAB 7.2 (R2006a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (13)
26 May 2006 Sean Wilson

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

28 Sep 2006 JON AM

GOOD PROGRAM

29 Nov 2006 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.

11 Dec 2006 Ken Campbell

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

02 Mar 2007 Aravind Ratnam

Could someone please post the 'fixed' version?

05 Sep 2007 kevin brown

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

30 Jan 2008 Ilse Van Tricht

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

14 Feb 2008 Jacob Bemrich

Exactly what I was looking for.

16 Mar 2008 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',',')

10 Apr 2008 Laura McCormack

Very nice! This is just what I needed.

09 Jun 2008 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?

29 Sep 2009 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.

15 Jul 2011 Cheol Hee

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

Please login to add a comment or rating.
Updates
12 May 2006

Updated description to better describe the functionality of the file

06 Dec 2006

Updated file

09 May 2007

Included reference to related "ezwrite" function in description

06 Sep 2007

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

Tag Activity for this File
Tag Applied By Date/Time
data import Paul Taylor 22 Oct 2008 08:24:44
data export Paul Taylor 22 Oct 2008 08:24:44
csv Paul Taylor 22 Oct 2008 08:24:44
read Paul Taylor 22 Oct 2008 08:24:44
mixed Paul Taylor 22 Oct 2008 08:24:44
text Paul Taylor 22 Oct 2008 08:24:44
arra Paul Taylor 22 Oct 2008 08:24:44
matlab Paul Taylor 22 Oct 2008 08:24:44
import Paul Taylor 22 Oct 2008 08:24:44
load Paul Taylor 22 Oct 2008 08:24:44
delimited Paul Taylor 22 Oct 2008 08:24:44
numeric Paul Taylor 22 Oct 2008 08:24:44
csv Matthew Wall 27 Feb 2009 16:12:07

Contact us at files@mathworks.com