Code covered by the BSD License  

Highlights from
Multi-Format CSV Reader

2.54545

2.5 | 11 ratings Rate this file 130 Downloads (last 30 days) File Size: 1.77 KB File ID: #6012
image thumbnail

Multi-Format CSV Reader

by Cole Stephens

 

07 Oct 2004 (Updated 20 Oct 2010)

MFCSVREAD reads a CSV file containing both text & numeric data.

| Watch this File

File Information
Description

"mfcsvread" reads a CSV file containing both text & numeric data. MATLAB's CSVREAD function will work with all numeric, or all text data, but not both. It's common to have a file with a single line of comma separated text headers followed by many rows of numeric data. xlsread is limited in the number of rows & colums (actually, Excel is the limitation) it can read.

The CSV file should look like:
comma, separated, text, ...
1,2,3,4,5,...
6,7,8,9,10,...
etc...

The output is a structure with the column headers as fields in a structure, each with a vector of data.

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (16)
14 Nov 2004 a matlab user

Could it be that the author posted the wrong file?

I could not get it to read a 'CSV file containing both text & numeric data' as advertised. In fact, the function calls CSVREAD:

%Read in the rest of the data (should be numeric)
fieldData=csvread(fileName,1,0);

so it can't seem to do anything CSVREAD can't do.

06 Jan 2005 Cole Stephens

The entire file can't be mixed. It's meant to read in a CSV file who's first row is text and all subsequent rows are numeric. It is documented in the help:

The CSV file should look like:
comma, separated, text, ...
1,2,3,4,5,...
6,7,8,9,10,...

28 Feb 2005 Francis Pieraut

The description is missleading and the filename also. A more appropriate description should be mfcvsread read std csv with text columns name as the first row.

06 Apr 2005 joe patiani

I found something strange in the Matlab for csvread function. In Matlab R13 the function can recognize R and C option, but not in R12. This option in R12 can`t be use just ignored by matlab.It seem like the option is useless. Could it be a bug in R12 version

03 Jun 2005 flo ben  
03 Oct 2005 Manu Raghavan

Function can't read data that's sorted as text in some columns and numbers in others. It WILL NOT work unless you have entirely numeric data with only a single text row for headers.

19 Apr 2006 Antoine Viellard

I recommand this for text cvs files :
http://www.antoine-viellard.com/tools/CSVImport.html

16 May 2006 Peder Axensten

If you need to read any kind of delimited text, use readtext (available here at File Exchange). Any mix of numbers and strings is handled.

09 Feb 2008 Scott B.

Autodataread.m in the FEX will definitely read CSV files whose contents include a mix of numeric and text columns.

23 Mar 2008 Ranga Roy Koduru  
28 May 2008 Alfred Haeusler  
12 Oct 2008 esam youssef  
13 Apr 2010 mathworks2011

very poor. as above

20 Apr 2010 cdvddt cdvddt

I do not agree with other comments:
The script does what it says in the description : It reads CSV data into a struct, and it does it right and fast.

I agree that the name is a bit misleading, but come on : Just learn to read a description.

Anyawy, thanks to the Author : that's excatly what I needed.

12 Jul 2011 Naren

This function is useless if you are trying to read the csv data that is mix of numbers and text. This doesn’t do much than just read a text header and rest of the data need to be 100% numeric.

23 Jan 2012 John

Since this code doesnt work to read text-numeric mixed files, does anyone have any suggestions for reading these?

Please login to add a comment or rating.
Updates
20 Oct 2010

Updated the license information.

Tag Activity for this File
Tag Applied By Date/Time
data import Cole Stephens 22 Oct 2008 07:32:40
data export Cole Stephens 22 Oct 2008 07:32:40
csv Cole Stephens 22 Oct 2008 07:32:40
xlsread Cole Stephens 22 Oct 2008 07:32:40
data Cole Stephens 22 Oct 2008 07:32:40
import Cole Stephens 22 Oct 2008 07:32:40
utilities Cole Stephens 22 Oct 2008 07:32:40
csv John 21 Oct 2009 14:21:43
csv cdvddt cdvddt 20 Apr 2010 09:06:51
csv Ankit 09 Jun 2010 01:43:50
csv Nha Vo Thanh 22 Jul 2010 01:59:48
csv Daniel Lander 30 Aug 2010 01:25:40
csv Philip 23 Feb 2011 11:10:52
csv Sainath 30 Nov 2011 06:08:37

Contact us at files@mathworks.com