importdata - Comma delimeter not working?
4 views (last 30 days)
Show older comments
Hi,
I'm trying to import data using the importdata function rather than xlsread (because of memory constratints --> importdata vs. xlsread).
My code reads as follows...
fid=dir('myfile.csv')
data=importdata(fid.name,',')
When I look at the data variable, it is a cell array, '<2252x1 cell>'.
The cell data{1} looks like this...
1,1,1,11481117,EXCITER GRO,11481117,C,,43,,,0,0,1,1,1,47,047XX,,ZCOM,,AEA,HALB
I would expect it to look like this, with every data point in its own column...
1 | 1 | 1 | 11481117 | EXCITER GRO | 11481117 | C | | 43 | | | 0 | 0 | 1 | 1 | 1 | 47 | 047XX | | ZCOM | | AEA | HALB
Am I missing something? Thanks!
-JF
2 Comments
dpb
on 9 Apr 2014
Am I missing something?
Ayup :) That there's mixed data in the file so A can't be anything but a cell array from importdata. It supports mixed data only for the headers in returning a double for numeric fields.
Your option if can't read it with xlsread is to use textscan with a specific format for the various numeric/character fields.
Answers (0)
See Also
Categories
Find more on Data Import and Export in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!