-
Notifications
You must be signed in to change notification settings - Fork 0
/
users.py
39 lines (29 loc) · 890 Bytes
/
users.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 28 09:32:09 2016
@author: JasonMedina
"""
import xml.etree.ElementTree as ET
import pprint
filename = "/Users/JasonMedina/Downloads/culver-city_sample.osm"
# get user attribute, uid also works
def get_user(element):
user = element.attrib['user']
return user
# returns set of unique users
def process_map(filename):
users = set()
for _, element in ET.iterparse(filename):
if element.tag == "node" or element.tag == "way":
users.add(get_user(element))
return users
# run function with process map
def run(filename):
users = process_map(filename)
# pprint.pprint will print a list of all users
pprint.pprint(users)
# execute run to see user names
run(filename)
# print user count
users = process_map(filename)
print len(users)