How to extract certain rows from an excel file?

1 vue (au cours des 30 derniers jours)
Akash Menon
Akash Menon le 14 Jan 2019
Hi all,
I have quite a large excel file wherein the first coloum is a 'timestamp' that goes on for several days. I only want to extract certain days data for example I would like to extract data from 2018-11-09 00:00:05.000 to 2018-11-10 00:00.05.000 or alternatively other dates too.
I basically want to extract all the other data next to it for those date ranges- any idea how to do that with xlsread?
Many thanks! (Image attached)
report.PNG

Réponses (2)

madhan ravi
madhan ravi le 14 Jan 2019
Use readtable() to read the file and then extract only the required datas.

Walter Roberson
Walter Roberson le 14 Jan 2019
MATLAB cannot know which rows satisfy your time bounds until it has read the data.
If you can count on the times being 10 seconds apart, then read A1:A1 to get the base time, and then calculate from it how many rows further on you need to go in order to reach the start of where you want to read, and also the end of where you want to read, and then ask to read those rows (either xlsread or readtable.)
If you cannot count on the times being 10 seconds apart, but you can count on the times being in increasing order, then since you seem to be using MS Windows (Excel for Mac has different colors than what you show), you could create an activeX control to talk to Excel, and have it read individual times, and do a binary search to find the rows for the start and end times.

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by