Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Wed Sep 24 22:12:20 2014
- @author: vikramk3
- """
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import xml.etree.ElementTree as ET
- import pprint
- import re
- """
- Your task is to explore the data a bit more.
- The first task is a fun one - find out how many unique users
- have contributed to the map in this particular area!
- The function process_map should return a set of unique user IDs ("uid")
- """
- def get_user(element):
- return
- def process_map(filename):
- # I added element.clear() after each iteration to avoid memory issues for the iterative parsing
- users = set()
- for _, element in ET.iterparse(filename):
- pass
- new_user=element.get("uid")
- if (new_user not in users) and (new_user != None):
- users.add(element.get("uid"))
- element.clear()
- return users
- def test():
- users = process_map('C:\\Users\\vikramk3\\Documents\\Courses\\Data_Wrangling\\austin_texas.osm')
- pprint.pprint(users)
- print "#of unique users= ", len(users)
- if __name__ == "__main__":
- test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement