Created
October 20, 2014 02:17
-
-
Save anonymous/7036b0d0ea8a616f09e7 to your computer and use it in GitHub Desktop.
This file contains 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 xml.etree.ElementTree as et | |
import urllib | |
import csv | |
feed = urllib.urlopen("https://api.sportsdatallc.org/ncaafb-rt1/2014/REG/schedule.xml?api_key=a3cctrtbt5sxtjgar9hjeemd") | |
raw_data = et.parse(feed) | |
root = raw_data.getroot() | |
feedlink = '{http://feed.elasticstats.com/schema/ncaafb/schedule-v1.0.xsd}' | |
results = [['week', 'gameid', 'scheduled', 'coverage', 'homerot', 'awayrot', 'home', 'away', 'status', 'venueid', 'country', 'name', 'city', 'state', 'capacity', 'surface', 'surftype', 'zipcode', 'address', 'temperature', 'condition', 'humidity', 'speed', 'direction', 'speed', 'direction', 'network', 'satellite', 'internet', 'cable', 'stats', 'href']] | |
for week in root.iter(tag = feedlink +'week'): | |
week = week.get('week') | |
for game in root.iter(tag = feedlink +'game'): | |
gameid = game.get('id') | |
scheduled = game.get('scheduled') | |
coverage = game.get('coverage') | |
homerot = game.get('home_rotation') | |
awayrot = game.get('away_rotation') | |
home = game.get('home') | |
away = game.get('away') | |
status = game.get('status') | |
print "Week: %r." % week | |
print "GameID: %r." % gameid | |
print "Scheduled: %r." % scheduled | |
print "Coverage: %r." % coverage | |
print "HomeRot: %r." % homerot | |
print "AwayRot: %r." % awayrot | |
print "Home: %r." % home | |
print "Away: %r." % away | |
print "Status: %r." % status | |
for venue in game.iter(tag = feedlink +'venue'): | |
venueid = venue.get('id') | |
country = venue.get('country') | |
name = venue.get('name') | |
city = venue.get('city') | |
state = venue.get('state') | |
capacity = venue.get('capacity') | |
surface = venue.get('surface') | |
surtype = venue.get('type') | |
zipcode = venue.get('zip') | |
address = venue.get('address') | |
print "Venue: %r." % venueid | |
print "Country: %r." % country | |
print "Name: %r." % name | |
print "City: %r." % city | |
print "State: %r." % state | |
print "Capacity: %r." % capacity | |
print "Surface: %r." % surface | |
print "Surface Type: %r." % surtype | |
print "Zip: %r." % zipcode | |
print "Address: %r." % address | |
for weather in game.iter(tag = feedlink +'weather'): | |
temperature = weather.get('temperature') | |
condition = weather.get('condition') | |
humidity = weather.get('humidity') | |
speed = weather.get('speed') | |
direction = weather.get('direction') | |
print "Temperature: %r." % temperature | |
print "Condition: %r." % condition | |
print "Humidity: %r." % humidity | |
for wind in game.iter(tag = feedlink +'wind'): | |
wind_speed = wind.get('speed') | |
wind_direction = wind.get('direction') | |
print "Speed: %r." % speed | |
print "Direction: %r." % direction | |
for broadcast in game.iter(tag = feedlink +'broadcast'): | |
network = broadcast.get('network') | |
satellite = broadcast.get('satellite') | |
internet = broadcast.get('internet') | |
cable = broadcast.get('cable') | |
print "Network: %r." % network | |
print "Satellite: %r." % satellite | |
print "Internet: %r." % internet | |
print "Cable: %r." % cable | |
for link in game.iter(tag = feedlink +'link'): | |
stats = link.get('rel') | |
href = link.get('href') | |
print "Rel: %r." % stats | |
print "Href: %r." % href | |
links=","+stats+","+href | |
results.append([week, gameid, scheduled, coverage, homerot, awayrot, home, away, status, venueid, country, name, city, state, capacity, surface, surtype, zipcode, address, temperature, condition, humidity, speed, direction, wind_speed, wind_direction, network, satellite, internet, cable, stats, href]) | |
# Save to csv | |
with open('NCAA.csv', 'wb') as f: | |
writer = csv.writer(f) | |
writer.writerows(results) | |
This file contains 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
week | gameid | scheduled | coverage | homerot | awayrot | home | away | status | venueid | country | name | city | state | capacity | surface | surftype | zipcode | address | temperature | condition | humidity | speed | direction | speed | direction | network | satellite | internet | cable | stats | href | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
2 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
3 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
4 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
5 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
6 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
7 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
8 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
9 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
10 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
11 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
12 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
13 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
14 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
15 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
16 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml | ||||||||||||||
17 | 5f614a5f-a5d2-4e2a-a3c6-b679b63a9ba5 | 2014-12-13T20:00:00+00:00 | full | ARM | NAV | scheduled | d2c78011-072a-4af2-a71f-aa73fdffe3fe | USA | M&T Bank Stadium | Baltimore | MD | 71008 | artificial | outdoor | 1101 Russell Street | CBS | roster | /2014/REG/16/NAV/ARM/roster.xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment