Skip to content

Instantly share code, notes, and snippets.

donlovett

Block or report user

Report or block donlovett

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@donlovett
donlovett / assign2_emaildb.py
Created Sep 30, 2016
Coursera Python DB Course Week2 Assignment 2
View assign2_emaildb.py
import sqlite3
conn = sqlite3.connect('orgdb.sqlite')
cur = conn.cursor()
dnsmapping = dict()
cur.execute('''
DROP TABLE IF EXISTS Counts''')
cur.execute('''
View xml4webfile.py
import urllib
import xml.etree.ElementTree as ET
#url = raw_input('Enter file: ')
#url = 'http://python-data.dr-chuck.net/comments_318170.xml'
url = 'http://64.137.250.177/comments_42.xml'
mycounter = 0
mysum = 0
while True:
View jason_webfile.py
import urllib
import json
# step 1 determine file to read from the web
# #url = raw_input('Enter file: ')
#url = 'http://python-data.dr-chuck.net/comments_42.json'
#url = 'http://python-data.dr-chuck.net/comments_318174.json'
url = 'http://64.137.250.177/comments_318174.json'
mycounter = 0
mysum = 0
countval = 0
@donlovett
donlovett / assign2_geojson.py
Created Sep 25, 2016
Final Assignment Week 6 Geojson
View assign2_geojson.py
import urllib
import json
serviceurl = 'http://python-data.dr-chuck.net/geojson?'
while True:
address = raw_input('Enter location: ')
if len(address) < 1 : break
url = serviceurl + urllib.urlencode({'sensor':'false', 'address': address})
View jason_webfile.py
import urllib
import json
# step 1 determine file to read from the web
# #url = raw_input('Enter file: ')
#url = 'http://python-data.dr-chuck.net/comments_42.json'
url = 'http://python-data.dr-chuck.net/comments_318174.json'
mycounter = 0
mysum = 0
# step 2 read web info into a dictionary
while True:
@donlovett
donlovett / jason_webfile.py
Created Sep 25, 2016
This is the first assignement for week 6 of the Python Data Course
View jason_webfile.py
import urllib
import json
# step 1 determine file to read from the web
# #url = raw_input('Enter file: ')
#url = 'http://python-data.dr-chuck.net/comments_42.json'
url = 'http://python-data.dr-chuck.net/comments_318174.json'
mycounter = 0
mysum = 0
# step 2 read web info into a dictionary
while True:
@donlovett
donlovett / xml4webfile.py
Created Sep 22, 2016
Final Week 5 Assignment to pull XML from Web and sum count element
View xml4webfile.py
import urllib
import xml.etree.ElementTree as ET
url = raw_input('Enter file: ')
#url = 'http://python-data.dr-chuck.net/comments_318170.xml'
mycounter = 0
mysum = 0
while True:
print 'Retrieving', url
@donlovett
donlovett / xml4localfile.py
Created Sep 22, 2016
update with stats labeled and debut prints out
View xml4localfile.py
import xml.etree.ElementTree as ET
#fname = raw_input('Enter the file name: ')
#fname = '/home/vagrant/Coursera/Week5/comments_42.xml'
fname = '/home/vagrant/Coursera/Week5/comments_318170.xml'
try:
tree = ET.ElementTree(file=fname)
print 'Retreived ',fname
#Retrieved 4204 characters
except:
print 'File cannot be opened:', fname
@donlovett
donlovett / xml4localfile.py
Created Sep 22, 2016
Read xml file and sum an attribute for Coursera Week 5
View xml4localfile.py
import xml.etree.ElementTree as ET
#fname = raw_input('Enter the file name: ')
#fname = '/home/vagrant/Coursera/Week5/comments_42.xml'
fname = '/home/vagrant/Coursera/Week5/comments_318170.xml'
try:
tree = ET.ElementTree(file=fname)
except:
print 'File cannot be opened:', fname
exit()
root = tree.getroot()
@donlovett
donlovett / wk4assign2_final.py
Created Sep 18, 2016
Week 4 2nd assignment
View wk4assign2_final.py
# Note - this code must run in Python 2.x and you must download
# http://www.pythonlearn.com/code/BeautifulSoup.py
# Into the same folder as this program
import urllib
from BeautifulSoup import *
countb = int(input("Enter a count: "))
position = int(input("Enter position: "))
url = 'http://python-data.dr-chuck.net/known_by_Lida.html'
You can’t perform that action at this time.