Exemple #1
0
def parsing_file(file_name):
    f = open(file_name, "r")

    rssi = "rss"
    fp_loc = "fp"
    ts = "timestamp"
    m_loc = "robots"

    output = {}
    output[rssi] = {}
    output[fp_loc] = {}
    output[ts] = {}
    output[m_loc] = {}
    sess_id = ""

    for line in f:
        line = line.replace("\"", "")
        line = line.strip()
        line = line.split(",")
        sess_id = line[1].strip()

        if output[rssi].get(sess_id, None) == None:
            output[rssi][sess_id] = []
        output[rssi][sess_id].append(line[2].strip())

        if output[fp_loc].get(sess_id, None) == None:
            output[fp_loc][sess_id] = []
        output[fp_loc][sess_id].append(fixed_point(line[3].strip()))

        if output[ts].get(sess_id, None) == None:
            output[ts][sess_id] = []
        output[ts][sess_id].append(line[4].strip())

        if output[m_loc].get(sess_id, None) == None:
            output[m_loc][sess_id] = []
        output[m_loc][sess_id] = (int(line[6].strip()), int(line[7].strip()))

    print output
    return output
Exemple #2
0
def parsing_file(file_name):
	f = open(file_name, "r")

	rssi = "rss"
	fp_loc = "fp"
	ts = "timestamp"
	m_loc = "robots"

	output = {} 
	output[rssi] = {}
	output[fp_loc] = {}
	output[ts] = {}
	output[m_loc] = {}
	sess_id = ""

	for line in f:
		line = line.replace("\"", "")
		line = line.strip()
		line = line.split(",")
		sess_id = line[1].strip()

		if output[rssi].get(sess_id, None) == None:
			output[rssi][sess_id] = []
		output[rssi][sess_id].append(line[2].strip())

		if output[fp_loc].get(sess_id, None) == None:
			output[fp_loc][sess_id] = []
		output[fp_loc][sess_id].append(fixed_point(line[3].strip()))

		if output[ts].get(sess_id, None) == None:	
			output[ts][sess_id] = []
		output[ts][sess_id].append(line[4].strip())

		if output[m_loc].get(sess_id, None) == None:
			output[m_loc][sess_id] = []
		output[m_loc][sess_id] = (int(line[6].strip()), int(line[7].strip()))

	print output
	return output
Exemple #3
0
from func import get_alpha, get_radius, get_area, get_distance
from fp import fixed_point
import csv

f = open("rssi_values (2).csv")

lst_p = []
lst_r = []
for line in f:
    lst_p.append(line[2])
    loc = fixed_point(line[3])
    lst_r.append(get_distance(loc[0], loc[1], int(line[6]), int(line[7])))

lst = zip(lst_p, lst_r)
lst = sorted(lst, key=lambda tup:tup[0], reverse=True)
lst = lst[0:3]
lst = zip(*lst)
lst_p = lst[0]
lst_r = lst[1]
print get_alpha(lst_p, lst_r)