How to delete multiple rows from an excel file?

3 visualizzazioni (ultimi 30 giorni)
Be
Be il 3 Set 2014
Commentato: Be il 2 Apr 2015
Hi,
I am (very) new to Matlab and am having real trouble with importing an excel file.
I have an extremely large excel file that has text, numbers and date/ times that all need importing. There are 25 columns and 104485 rows. When I import it using the import tool it returns everything with an NaN. I think this is because some of the rows have not got correctly formatted values in them and have a text value (as far as I can see it's \N).
So, what I need to do is remove all of the rows where this is occurring so I can import the rest of the data correctly.
NB. I have another data set that is exactly the same layout that does not have dodgy data in some of the rows and that imports perfectly with no issues at all.
Any help would be much appreciated as I'm really struggling here!
Thank you in advance!
  1 Commento
dpb
dpb il 3 Set 2014
Besides the answer of Yona which is generally good advice to use xlsread and post-process, I'd suggest showing a small subsection of the file that illustrates the form of the data so others can look--there may be other things that can be done, depending...

Accedi per commentare.

Risposta accettata

Yona
Yona il 3 Set 2014
Modificato: Yona il 4 Set 2014
when you import data by xlsread function, you get 3 matrix. one of numbers, one of text and one with both of them and it is a cell matrix.
when you import file:
  • in number matrix you get all column that have at least one number and all text and empty cell is NaN.
  • In text you get all column that have at least one text and all number is '' (empty string).
  • In cell matrix you get all data and all empty cell are NaN.
another thing, if you know what is the column you want, you can import only them.
look xlsread.m.
If you want remove the column after they is in matlab, just use isnan.m to find with column or row have a NaN value

Più risposte (0)

Categorie

Scopri di più su Data Import from MATLAB 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