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
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
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.
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!