#!/usr/bin/env python

import fileinput

mac_index = 12
time_index = 1
MAC_LEN = 17
SAMPLE_PERIOD = 300 # Seconds. 5 minutes.
maclist = []
buffer = {}
# TODO: add maclists to buffer every sample period.
# TODO: Upload buffer to AWS every collection period.
for line in fileinput.input():
    splitline = line.split(" ")
    if mac_index < len(splitline):
        mac = splitline[mac_index]
        if mac == "DA:Broadcast":
            mac = splitline[mac_index+1]
        ts = splitline[time_index]
        mac = mac[len(mac)-MAC_LEN:]
        if mac not in maclist:
            maclist.append(mac)
        print ts,mac

@@ -64,16 +64,31 @@
 dex = 1%0A
+start_t_us = 0%0A
 MAC_LEN 
@@ -110,17 +110,16 @@
 IOD = 30
-0
  # Secon
@@ -137,84 +137,80 @@
 es.%0A
-maclist = %5B%5D%0Abuffer = %7B%7D%0A# TODO: add 
+PUSH_TO_AWS_PERIOD = 3600 # Seconds. One hour.%0A
 maclist
-s to 
+ = %5B%5D%0A
 buffer 
-every sample period.
+= %7B%7D%0A
 %0A# T
@@ -481,16 +481,20 @@
    ts = 
+int(
 splitlin
@@ -502,24 +502,30 @@
 %5Btime_index%5D
+%5B:-2%5D)
 %0A        mac
@@ -617,25 +617,261 @@
 ac)%0A
-        print ts,mac
+%0A        if start_t_us is 0:%0A            start_t_us = ts%0A        elif ts - start_t_us %3E (SAMPLE_PERIOD * 1000000):%0A            buffer%5Bstart_t_us%5D = maclist%0A            maclist = %5B%5D%0A            start_t_us = 0%0A        print ts,mac%0A%0A#print buffer, len(buffer)
 %0A

Add sampling time machinery