-1
I have a file that the lines have this pattern:
0.22755189537 SN.node[0].Application SENDING BEACON # 0
0.22755189537 SN.node[0].Application Sending [Beacon] of size 105 bytes to communication layer
0.22755189537 SN.node[0].Communication.Radio Buffered [BypassRouting packet] from MAC layer
0.22755189537 SN.node[0].Communication.Radio SET STATE to TX, delay=1e-05, power=62
0.227561895369 SN.node[1].Communication.Radio START signal from node 0 , received power -87.6124dBm
0.231689895368 SN.node[0].Communication.Radio TX finished (no more pkts in the buffer) changing to RX
0.231689895368 SN.node[1].Communication.Radio END signal from node 0
0.231689895368 SN.node[1].Communication.Radio Received packet (WC_SIGNAL_END) from node 0, with no interference
0.231699895368 SN.node[1].Application RECEBIDO BEACON #0 - ORIGEM 0 - SALTOS 0
I tried to split to get the value between [ ], like this: x.split()[1]. split('[')[1][0] but gives Indexerror error: list index out of range.
It worked correctly, but I was trying the split, because I need other information from the line as well. To clarify: I take the value of a node (0 or 1) and then in the third part I have an occurrence. I want to check how many occurrences have arisen of the RECEIVED type for each node (only one counter) and how many SENDING occurrences have also occurred for each node.
– ARSaraiva
What it would look like to get out of what you need?
– Éder Garcia
Right now it’s pretty simple, something like: Node[0] - x SENT
– ARSaraiva
Node[1] - x RECEIVED
– ARSaraiva
In fact there are in all 36 nodes (0 to 35) and I would have to read the file, and check each of the nodes how many RECEIVED and how many SENDING occurred.
– ARSaraiva
Only I do not know where to start with 36 knots, with two I thought of if/Else (if it is 1...if not 0, kkk)
– ARSaraiva
With 36 I thought of creating a case with 36 entries, each row corresponds to a node, so the corresponding row in the case would have a received if (received ++) Elif sending (sendingx ++) Else nothing. But I don’t know if my logic is right.
– ARSaraiva
finally the output could be equal to a table
– ARSaraiva
Node | SENT | RECEIVED
– ARSaraiva
1 | xxxx | xxxx
– ARSaraiva
I don’t know if you understood how it works to slice the line... For example:
linha[26:27]
returns only0
or1
because it begins to slice on column 26 and ends on 27. If it werelinha[25:28]
the exit would be[0]
or[1]
and so on. Modify in the example of my answer to better understand. Try the logic you imagined and if it doesn’t work ask a new question. Good luck!– Éder Garcia
Eden, after I followed this logic and the idea you gave me, I realized it didn’t work
– ARSaraiva
note that there are more than 100,000 lines enter the append only works in the first part
– ARSaraiva
Post your code and error message (if you have).
– Éder Garcia
Éder, I’ve changed a lot of things and managed to improve a little, using the split. But it’s still a long way to go. If you want to take a look https://repl.it/repls/GrizzledVillainousDebuggers
– ARSaraiva
I looked at the code. The logic is wrong. I need to understand what you want to do. So let’s see if I understand you: If
SENDING
orSending
is equal to1
thencontador_send
is incremented. Then, ifReceived
orRECEBIDO
is equal to1
thencontador_recebido
is incremented. This is what you need?– Éder Garcia
Hello Eden, it would not be that. I managed to do after catching a little. Look, I have two nodes that send x packages between them. I need to count how many packets each node sent and how many each node received. Then I did an if to check if the node is 0, if not, it can only be 1. Inside the if/Else I did a second if checking RECEIVED, but SENDING. That’s the logic I followed.
– ARSaraiva
I am glad that it worked. With patience and persistence to overcome a lot of things. I am glad that you succeeded in your endeavor. Congratulations!
– Éder Garcia