2.625

2.6 | 8 ratings Rate this file 289 downloads (last 30 days) File Size: 1.83 KB File ID: #6012

Multi-Format CSV Reader

by Cole Stephens

 

07 Oct 2004 (Updated 11 Oct 2004)

No BSD License  

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

Download Now | 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 (12)
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  
Please login to add a comment or rating.
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
utilities Cole Stephens 22 Oct 2008 07:32:40
import Cole Stephens 22 Oct 2008 07:32:40
data Cole Stephens 22 Oct 2008 07:32:40
csv John 21 Oct 2009 14:21:43
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com