-
-
Save nipunbatra/5744187 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import pprint | |
import csv | |
file = open( "filename_destination2.csv", "w") | |
files_in_dir = os.listdir('/home/shailja/readfiles') | |
fileWriter = csv.writer(file , delimiter=",",quotechar='"', quoting=csv.QUOTE_MINIMAL) | |
Header = ['timestamp','rssi'] | |
fileWriter.writerow(Header) | |
string = "" | |
for file_in_dir in files_in_dir: | |
f = open(file_in_dir,'r') | |
line = f.readlines() | |
i=5 | |
while i <= len(list(line)): | |
i=i+1 | |
output =[] | |
t=json.loads(line[i]) | |
#print line[i] | |
ssid= t["ssid"] | |
row = {} | |
if ssid =='STUDENTS': | |
row['timestamp'] =t['timestamp'] | |
row['rssi'] =t['rssi'] | |
output.append(row) | |
for x in output: | |
te = [x['timestamp'],x['rssi']] | |
fileWriter.writerow(te) | |
#if i >= len(list(line))+1: | |
# break | |
f.close() | |
file.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment