# Iterating through data from multiple channels

**URL:** <https://forum.qoitech.com/t/iterating-through-data-from-multiple-channels/281>\
**Category:** Support\
**Created:** [April 2, 2019, 6:19pm UTC](https://forum.qoitech.com/t/iterating-through-data-from-multiple-channels/281 "2019-04-02T18:19:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brendend](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@brendend](https://forum.qoitech.com/u/brendend)\
**Post date:** [April 2, 2019, 6:19pm UTC](https://forum.qoitech.com/t/iterating-through-data-from-multiple-channels/281/1 "2019-04-02T18:19:45Z")

</div>

Hello,

I need my script to process both main current and main energy data while running a test. I need to do this every 10 seconds and get only the last 10 seconds of data from these channels to perform the processing on. I am using these calls:

```
        local mc_count = project:get_channel_count(box, recording_id, "mc")
        local mc_data = project:get_channel_data(box, recording_id, "mc", prev_count, mc_count)

        local me_count = project:get_channel_count(box, recording_id, "me")
        local me_data = project:get_channel_data(box, recording_id, "me", prev_count, me_count)

```

prev\_count is the count from the last time I made these calls.

Even using prev\_count, I sometimes get data that is earlier than I wanted. I also have to then match up the mc data and me data based on timestamp, which is slow when the program is running.

Is there a better way to do this? Is there a way I can get data by timestamp (rather than index)? Is there a way I can get both me and mc data without having to manually match up the samples?

Thanks!

---

<div class="post-metadata">

**Author:** ![bjorn.rosqvist](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.qoitech.com/bjorn.rosqvist/32/238_2.png) [@bjorn.rosqvist](https://forum.qoitech.com/u/bjorn.rosqvist)\
**Post date:** [April 3, 2019, 8:31am UTC](https://forum.qoitech.com/t/iterating-through-data-from-multiple-channels/281/2 "2019-04-03T08:31:31Z")

</div>

Hi,

Right now, there is no lua API for getting data by timestamp but I will add this in the back-log.

To minimise the difference you could have get\_channel\_count for me directly after get\_channel\_count for mc and then both get\_channel\_data.

Best regards,  
Björn
