Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#"" latitude longitude senseStartTimeMillis uid phq9 accuracy depressed period
import os
# map uid to os_
map_uid_os_ = dict()
for l in open('mapping.csv').readlines():
if len(l)>0:
ll = l.split(',')
if len(ll)>1:
uid = ll[0]
os_ = ll[2][:-1]
map_uid_os_[uid]=os_
owdict = dict()
# Userid,BSSID:,State,senseStartTimeMillis:
title = dict()
with open('wifi.csv', encoding='utf-8', errors='ignore') as file:
for line in file:
#print(line)
#break
ll = line.split(',')
if len(ll)>9:
uid = ll[1]
ts = ll[4]
state = ll[10]
bssid = ll[13]
if state =='Connected':
state = '1'
else:
state = '0'
if uid in map_uid_os_.keys():
os_ = map_uid_os_[uid]
if not os.path.exists(os_):
os.makedirs(os_)
firstline='Userid,BSSID:,State,senseStartTimeMillis:\n'
fn = os_+'_wifiraw\\'+uid+'.csv'
if not os.path.exists(os_+'_wifiraw\\'):
os.makedirs(os_+'_wifiraw\\')
if fn not in owdict.keys():
ow = open(fn,'a+')
owdict[fn]=ow
else:
ow = owdict[fn]
if fn not in title.keys():
title[fn]=1
ow.write(firstline)
ow.write(','.join([uid,bssid,state,ts])+'\n')
ow.flush()
for k in owdict.keys():
owdict[k].close()