Why is importdata bringing in cell array?
Afficher commentaires plus anciens
I have two different .csv files that I would like to import and create structure arrays.
I'm using this:
A = importdata(filepath, filename);
The first one works and the heading looks like this:

The second one comes in as cell array so I cannot grab A.data:

What is the difference that I'm not seeing?
3 commentaires
dpb
le 16 Nov 2018
Not possible to tell for certain w/o actual files nor is it clear what the definition of "works" is...and, of course you can dereference a cell array to retrieve whatever it is that is wanted from it... :)
With a (largeish) assumption about the above, what appears different visually is there's a blank row after the header rows before the numeric data in the first but not in the second--that may be sufficient of a clue to importdata without additional help to be able to find the array in the former that doesn't succeed in the latter--but that's a guess.
You might, instead, try using detectImportOptions first and then readtable for both; it quite possibly may take some intervention regarding knowledge of the file format to be totally successful; expecting magic to occur is, on occasion, not yielded in results...
K
le 16 Nov 2018
dpb
le 17 Nov 2018
What data, specifically are you wanting and how do you expect MATLAB to know where those data are or how they're organized for any totally arbitrary file excepting by some sort of preprocessing procedure?
detectImportOptions is the TMW-supplied routine to make a stab at that; anything else you do will be some variant of the techniques used therein.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Large Files and Big Data dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
