These values are in timestamp:
In python2.7 you can import the datetime
to make conversions of timestamp
>>> import datetime
>>> datetime.datetime.fromtimestamp(1488498263.14)
datetime.datetime(2017, 3, 2, 20, 44, 23, 140000)
>>>
As an example I used your first timestamp=1488498263.14
note the function return notation which is equivalent to year/month/day hour/minutes/seconds = 2/3/2017 20:44:23, you just take the return data and mount it the way you want it!
One way to get the values you need is not to convert the timestamp, if you want to take the values every 10 minutes then add the first timestamp + 10 min in timestamp and go saving the values that are less or equal to the value of timestamp + 10, OK you took 10 min of data, now for the next timestamp you make the same logic sum the next timestamp + 10 again and go walking and keeping all values that is less or equal and do this until the end, the logic is this:
First value + 10 min timestamp:
1488498263.14+ 10 * 60 = 1488498863.14
Walk on your go keeping all values/lines that are less than or equal to 1488498863.14, when you find a higher value add that value + 10 * 60 again and store all values within that period, do this until the end, there is no easy way use logic...
pkts = [1488498263.14, 1488498263.15, 1488498263.15, 1488498263.15, 1488498263.31, 1488498263.31, 1488498263.31, 1488498263.6, 1488498263.78, 1488498264.49, 1488498264.49, 1488498264.49, 1488498264.49, 1488498264.5, 1488498264.5, 1488498264.5, 1488498264.5, 1488498265.07, 1488498265.07]
somaMin = pkts[0] + 1
valores=[]
for p in pkts:
if p<=somaMin:
#armazenando os valores que estiverem dentro do intervalo de tempo
valores.append(p)
else:
#processe aqui tudo que tem no vetor valores, eles vão conter os dados no intervalo desejado
#apagando tudo que tem dentro do vetor para receber os próximos dados
valores=[]
#armazenando o próximo valor
valores.append(p)
#somando o valor novamente
somaMin=p+ 1
#processe aqui tudo que restou no vetor valores, eles vão conter os dados que sobraram
I don’t have all the data from your Sniffer, but using the data you showed, it’s about 2 seconds, so I did:
somaMin = pkts[0] + 1
But in your case change the somaMin to be + 10 * 60
somaMin = pkts[0] + 10 * 60
Don’t forget inside Isis either:
somaMin=p+ 10 * 60
I can’t be any clearer than that lol
I would like to scan the dump by picking up packages every 10 minutes until the end of the file. How to do it simply?]
– Ed S
thanks for the help!
– Ed S
will not be simple mt, see if you understand the logic in the answer....
– ederwander
Sorry for my ignorance. I have a little difficulty in enteder. Please don’t take this the wrong way!
– Ed S
huahuahua edited with a code see if now you understand ....
– ederwander
I have tried here: http://imgur.com/a/nLnRC
– Ed S
I only get errors: packets[counter] = temp Indexerror: list assignment index out of range
– Ed S
What can it be?
– Ed S
First, your code does not make sense, does not have the logic you want, according to your counter is passing the size of the list packets alias it does not exist is always empty, your code is full of errors and bugs, the logic of how to pick up the values in the interval you need is in the answer, follow it ...
– ederwander
I will study the answer calmly. Can I ask questions tomorrow? I will try to do without looking
– Ed S
OK can yes :-)
– ederwander
I tried running the dump here and gave this error: "somaMin = pkts[0] + 1 Typeerror: Unsupported operand type(s) for +: 'Ether' and 'int'"
– Ed S
should be pkts[0]. time + 1, remember I don’t have your file, my code works with the vector of values that you showed, adapt to q needs there ...
– ederwander
thank you! I am trying to add another functionality to the above code. Not to lengthen here, I will now create another question!
– Ed S