File Exchange

image thumbnail

Multi-Format CSV Reader

version 1.1.0.1 (1.83 KB) by

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

2.66667
15 Ratings

2 Downloads

Updated

View License

"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.

Comments and Ratings (20)

Victor

Victor (view profile)

It did what I wanted: read the heading and construct a struct with fields based on the heading

Bara'a

Bara'a (view profile)

the description is indeed misleading ... it didn't work at all with my mixed data types in the csv file :(

SpartanG72

Zambezy

It did not work from the file download but after copy and paste of the code it worked like a charm...

John

John (view profile)

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

Naren

Naren (view profile)

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.

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.

mathworks2011

very poor. as above

esam youssef

Alfred Haeusler

Ranga Roy Koduru

Scott B.

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

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.

Antoine Viellard

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

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.

flo ben

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

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.

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,...

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.

Updates

1.1.0.1

Updated license

1.1

Updated the license information.

MATLAB Release
MATLAB 7.0.1 (R14SP1)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video