====== logreader.py (estimote beacons) ====== import dateutil.parser, subprocess, codecs, random, time logs = subprocess.Popen("ls -RSl *csv | head -10", \ shell=True, stdout=subprocess.PIPE, \ stderr=subprocess.PIPE).communicate()[0].strip() print logs toRead = raw_input("choose a file: (you can use one from the list above)\n") fileOut = codecs.open("vizi/visualize.csv", "w", encoding="utf-8") fileOut.write("user,user_time,positionx,positiony,bajts\n") log = codecs.open((toRead), "r", encoding="utf-8") #log = codecs.open(("logging-2014-09-03.csv"), "r", encoding="utf-8") color_list = ["#19B2AE","#FF29D2","#3DFFF9","#CCAF25","#CC2925","#B2AB88"] users = {} blueberry = ["336", "284"] icy = ["534", "201"] mint = ["710", "273"] ### the loop ui=0 for i, line in enumerate(log): if i==0: begin_time = int(time.mktime(dateutil.parser.parse(line.split(",")[2].strip('"')).timetuple())) print i, line, begin_time else: # get the user (if unique assign a new colour; if existent, add data to it) user = line.split(",")[1].strip('"') if user not in users: if user == 'noID': users[user]=("#B2AB88") fileOut.write(users[user]+",") else: print 'current ui', ui users[user]=(color_list[ui]) fileOut.write(users[user]+",") ui=ui+1 else: fileOut.write(users[user]+",") pass # get user time user_time = int(time.mktime(dateutil.parser.parse(line.split(",")[2].strip('"')).timetuple())) print user_time interval= str(user_time-begin_time) print interval, user fileOut.write(interval+",") # get user's position and translate it into screen position position = line.split(',')[8].strip('"\n') if position == "62100": fileOut.write(blueberry[0]+","+blueberry[1]+",") elif position == "55745": fileOut.write(icy[0]+","+icy[1]+",") elif position == "56336": fileOut.write(mint[0]+","+mint[1]+",") else: fileOut.write("1024,326,") #data bajts = abs(int(line.split(",")[3].strip('"'))) fileOut.write(str(bajts)+"\n") print users fileOut.close() ====== logreader.py (wi-fi fingerprints) ====== import dateutil.parser, subprocess, codecs, random, time logs = subprocess.Popen("ls -RSl *csv | head -10", \ shell=True, stdout=subprocess.PIPE, \ stderr=subprocess.PIPE).communicate()[0].strip() print logs toRead = raw_input("choose a file: (you can use one from the list above)\n") fileOut = codecs.open("vizi/visualize.csv", "w", encoding="utf-8") fileOut.write("user,user_time,positionx,positiony,bajts\n")