readtable changing range (not all contents)
조회 수: 40(최근 30일)
Manually Importing an XLS file (right click import data) the window by default highlights a matrix, say C10:X90
If I manually change the default "column vectors" to "table" and then click import, then it imports the matrix I need.
I need to do this for many files. However, using readtable('file1.xls') it imports all contents, beyond that matrix.
The matrix range changes from file to file so I cannot fix it to C10:X90, so file2.xls can be C15:X80, etc
How can I import the highlighted matrix (which changes from file to file) in a loop?
Cris LaPierre 2018년 12월 14일
편집: Cris LaPierre 2018년 12월 14일
Not sure how to detect the end of your dataset before using readtable, but what about reading it in and then deleting the extra rows? For this, I'm assuming Title1 will be populated for every row that has data. Adjust for how your data actually behaves.
opts = detectImportOptions('Importing.xls');
tbl = readtable('Importing.xls',opts)
tbl(ismissing(tbl.Title1),:) = 
Probably worth stating that this also assumes every file has a column header Title1 that contains the Char2, ... values.