views:

177

answers:

1

I have a file of the following format.

"08-10-2010 13:29:31      1 APs were seen
"
"08-10-2010 13:29:31      MAC Address         SSID                          RSSI"
"08-10-2010 13:29:31      00:1e:79:d7:d5:b0                                 -80"
"08-10-2010 13:30:32      2 APs were seen
"
"08-10-2010 13:30:32      MAC Address         SSID                          RSSI"
"08-10-2010 13:30:32      00:1e:79:d7:d5:40                                 -93"
"08-10-2010 13:30:32      00:1e:79:d7:d5:b0                                 -78"
"08-10-2010 13:31:33      2 APs were seen
"
"08-10-2010 13:31:33      MAC Address         SSID                          RSSI"
"08-10-2010 13:31:33      00:1e:79:d7:d5:40                                 -94"
"08-10-2010 13:31:33      00:1e:79:d7:d5:b0                                 -79"
"08-10-2010 13:32:34      1 APs were seen
"
"08-10-2010 13:32:34      MAC Address         SSID                          RSSI"
"08-10-2010 13:32:34      00:1e:79:d7:d5:b0                                 -94"
"08-10-2010 13:33:35      1 APs were seen
"
"08-10-2010 13:33:35      MAC Address         SSID                          RSSI"
"08-10-2010 13:33:35      00:1e:79:d7:d5:b0                                 -88"
"08-10-2010 13:34:36      1 APs were seen
"
"08-10-2010 13:34:36      MAC Address         SSID                          RSSI"
"08-10-2010 13:34:36      00:1e:79:d7:d5:b0                                 -82"

As you can see from the copied text, at every instant of time, a computer might see 1 or 2 or 3 (or maybe more) number of APs. I need to create the following file: 1. The file will have a date and time (specified as a datetime object). It needs to go and check the file and return the MAC addresses of the two APs which have the highest RSSI values.

Now as you can see from the file at some times the computer will see only one AP. In that case the function has to return the MAC address of that AP, and "none" as the second return value. When there are more than two APs recorded at that time, then it has to return the highest two.

How would I do this?

A: 

http://docs.python.org/library/

Look carefully at sections 10 and 7. They will give you what you need to look at a file and parse it for the information required. Study, post something, whether it works or not, and we'll help you out more.

MaQleod