How can I extract only cells with a value in specific column from excel?

조회 수: 9 (최근 30일)
Is there a way to specify the starting row and continue to the bottom of that column of numbers without specifying the exact row it ends at? I have excel files where the values start in A5, and then there is a variable number of values in that column (100-200) in each file. I know how to specify the range if I know the end value (eg 'A5:A142') and I know I can specify the whole column ('A:A') but I don't know how many rows will be in any given file so I can't specify the endpoint, and when I do the whole column it takes a very long time and I end up with a 1048576x1 cell filled mostly with NaN.
  댓글 수: 1
dpb
dpb 2018년 8월 9일
Might try IA's ActiveX script to see if it will find the last row for you to then use. Find-last-row-in-excel
I generally just read the sheet and return the raw cell array which can be used to find out such stuff. If it isn't too big that generally while not particularly clever doesn't take too long.
Or if it is to get the numeric data, again just return it all and throw away what don't want.

댓글을 달려면 로그인하십시오.

채택된 답변

Kellie Wilson
Kellie Wilson 2018년 8월 9일
편집: Kellie Wilson 2018년 8월 9일
Never mind, I think I got it. If use [~,~,data] = xlsread('myfile.csv','A:A') then it returns the 1048576x1 cell. But, if I just do data = xlsread('myfile.csv','A:A') then it automatically starts where the data begins and stops where it ends. I'm not sure if this will work for .xlsx files, but it works for my .csv files
  댓글 수: 2
dpb
dpb 2018년 8월 9일
"But, if I just do data = xlsread('myfile.csv','A:A')"
Assuming all you want/need is numeric, yes, it also works for .xls, .xlsx, .xlsb, ...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by