importdata - Comma delimeter not working?

5 visualizzazioni (ultimi 30 giorni)
John
John il 9 Apr 2014
Commentato: dpb il 9 Apr 2014
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 Commenti
John
John il 9 Apr 2014
Additionally, I'm exporting the file from Excel to the .csv format.
dpb
dpb il 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.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Large Files and Big Data in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by