I'm trying to bruteforce through some list iterations in python (I'm a pynoob) and I can't seem to understand why this is such an issue.
My data structure looks like this:
pprint.pprint(list)
[[1355759452000L, 1],
[1355759191000L, 1],
[1355758983000L, 1],
[1355758939000L, 1],
... items removed for brevity...
[1355742844000L, 1],
[1355742833000L, 1],
[1355742558000L, 1]]
I want to iterate over this list, however, the only way I was able to get the timestamp from this was to perform the following (seems wrong):
startEpoch = 0
endEpoch = ...some future date...
newList = []
while currentTime <= endEpoch:
for i,l in enumerate(list):
for epoch in enumerate(l):
if epoch[1] >= currentTime and epoch[1] <= (currentTime + 7200):
newList.append(currentTime)
currentTime += 7200
The goal of this is to iterate over 'list' and add up ever entry that falls with a 2 hour range. So, if the start is 0, count each entry between 0 and 7200, then count each entry between 7200 and 14200, etc.
Ideally, I want newList to be something like:
[0][12]
[7200][11]
[the time stamp][the count]
For whatever reason, my bad habits in other languages and my lack of understanding in python, this is becoming error prone and way more difficult than it should be.
Any help and guidance is appreciated.