Learn Python Through Public Data Hacking

Next Day Video · 848K views · 2013 · 2:38:22

Open on YouTube

Python, Ruby & scripting languagesEducation & learningtutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it because learners follow along with its exercises and then hit problems, such as Python 2 vs 3 changes to urllib, XML parsing quirks, and the dead bus-tracker URL.

Recommended by 1 people across 1 different months, 2013 to 2018.

What it is

David Beazley's 2.5-hour PyCon tutorial teaches Python basics through a hands-on project. Viewers read files, scrape the web, build data structures, and analyze real Chicago bus-tracking data to solve a puzzle.

What people said

Recommends AndTuf · 2017-06 · Stack Overflow · on “Can't spot a bug in my python code”

I'm learning a bit of python coding and I'm following this youtube video [this video] too to make some practice. Now here is what I'm running. import urllib import operator from xml.etree.ElementTree import parse import webbrowser from showmap import showmap def getbuses(): u = urllib.urlopen(' [LINK] ') data = u.read() f = open('rt22.xml', 'wb') f.write(data) f.close() doc = parse('rt22.xml') running_buses = {} for bus in doc.findall('bus'): idbus = int(bus.findtext('id')) lat = float(bus.findtext('lat')) lon = float(bus.findtext('lon')) direction = str(bus.findtext('d')) running_buses[idbus] = {lat, lon, direction} return running_buses def print_routes(running_buses): print 'Running buses on ro

Cites Phix · 2013-11 · Stack Overflow · on “Python loop appending same object twice”

I'm following the YouTube video Learn Python through Data Hacking [this video] and am expanding on the sort of "legacy" inline way by adding classes to learn all the ins and outs of Python OOP. Basically the guy in the video has you grab the Chicago bus line's route, parse it, and find which bus his friend left his suitcase on by comparing lat, long, time, distace, etc. The XML file I'm working with has a bunch of values like so: <bus> <id>1867</id> <rt>22</rt> <d>North Bound</d> <dd>Northbound</dd> <dn>N</dn> <lat>41.89167051315307</lat> <lon>-87.6297836303711</lon> <pid>5421</pid> <pd>Northbound</pd> <run>P258</run> <fs>Howard</fs> <op>30090</op> <dip>8858</dip> <bid>7323012</bid> <wid1>0P</wid

Cites Robert Birch · 2014-03 · Stack Overflow · on “XML Module Parsing Differences Between 2.7.6 and 2.7.3 in Python”

I am using this this tutorial [this video] to go through some concepts of Python, however, I ran into this problem trying to use this line of a code in 2.76. Dave is using 2.73 at the 53 minute part of the video in the monitor.py file. I am using this line of code to try to fix an error... from xml.etree.ElementTree import parse As oppose to import xml.etree.ElementTree import parse (which is what is used in the video in python 2.7.3) however it doesn't work when I use it. I get this error instead. PS C:\python27> python monitor.py Traceback (most recent call last): File "monitor.py", line 28, in <module> monitor() File "monitor.py", line 15, in monitor doc = parse(u) File "C:\Python27\lib\xml\et

Cites user3125707 · 2014-07 · Stack Overflow · on “python script from youtube video doesn't work”

I am trying to learn python from this youtube video: [this video] In the video they have given the viewers a script to run: ">>> import urllib" ">>> u = urllib.urlopen(' [LINK] ')" ">>> data = u.read()" ">>> f = open('rt22.xml','wb')" ">>> f.write(data)" ">>> f.close()" which pulls up data from a website and saves it in an xml file. But when I check the xml file I only get this: XML Parsing Error: no element found

Cites a. j. · 2018-07 · Stack Overflow · on “replacement in Python 3.6 for u = urllib.urlopen('http://ctabustracker.com/bustime/map/getBusesForRoute.jsp?route=22')”

import urllib u = urllib.urlopen(' [LINK] map/getBusesForRoute.jsp?route=22') data = u.read() f = open('rt22.xml', 'wb') f.write(data) f.close() In python 3.6, what function replaces urllib.urlopen? from: [this video] at 17.41