Skip to content

Instantly share code, notes, and snippets.

@kreed
Created March 30, 2015 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kreed/6a951a3cf3b01d8d11fb to your computer and use it in GitHub Desktop.
Save kreed/6a951a3cf3b01d8d11fb to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Extracts T-Mobile cells from from Mozilla Location Service data
#
# Usage: Download an MLS export from https://location.services.mozilla.com/downloads
# and run with mls.py MLS-full-cell-export-XXXXXXXXX.csv.gz [low sector] [high sector]
from __future__ import print_function
import gzip
import sys
import time
low_sector = int(sys.argv[2])
high_sector = int(sys.argv[3])
file = gzip.GzipFile(sys.argv[1], 'r')
print('lon,lat,gci,sector,range,samples,created,updated')
for line in file:
if line[0:12] == 'LTE,310,260,':
radio, mcc, net, area, cell, unit, lon, lat, range, samples, changeable, created, updated, averageSignal = line.split(',')
sector = int(cell) & 0xff
if sector >= low_sector and sector <= high_sector:
created = time.strftime('%Y-%m-%d', time.gmtime(int(created)))
updated = time.strftime('%Y-%m-%d', time.gmtime(int(updated)))
print(lon,lat,cell,sector,range,samples,created,updated,sep=',')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment