How to delete multiple rows from an excel file?

3 次查看(过去 30 天)
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 个评论
dpb
dpb 2014-9-3
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...

请先登录,再进行评论。

采纳的回答

Yona
Yona 2014-9-3
编辑:Yona 2014-9-4
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

更多回答(0 个)

产品

Community Treasure Hunt

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

Start Hunting!

Translated by