Skip to content

Commit

Permalink
Some tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed Apr 6, 2016
1 parent 725f3a2 commit 00b4a06
Show file tree
Hide file tree
Showing 22 changed files with 149 additions and 34 deletions.
33 changes: 33 additions & 0 deletions assn/gmane/peer1.json
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"title":"Mailing List Data - Part I",
"description":"In this assignment you will download some of the mailing list data from http://mbox.dr-chuck.net/ and run the data cleaning / modeling process and take some screen shots.",
"grading":"Don't take off points for little mistakes. If they seem to have done the assignment give them full credit. Feel free to make suggestions if there are small mistakes. Please keep your comments positive and useful.",
"solution" : "http://www.dr-chuck.net/pythonlearn/code/gmane.zip",
"parts":[
{
"title":"A screen shot of your SQLiteBrowser showing messages downloaded from mbox.dr-chuck.net into the content.sqlite database",
"type":"image"
},
{
"title":"A screen shot of you running the gmodel.py application to produce the index.sqlite database.",
"type":"image"
},
{
"title":"A screen shot of your SQLiteBrowser showing messages in the index.sqlite database after the gmodel.py has executed.",
"type":"image"
},
{
"title":"A screen shot of you running the gmbasic.py program to compute basic histogram data on the messages you have retrieved.",
"type":"image"
}
],
"totalpoints":10,
"instructorpoints":0,
"peerpoints":4,
"assesspoints":2,
"minassess":3,
"maxassess":10,
"flag":true,
"rating":0,
"gallery":"off"
}
33 changes: 33 additions & 0 deletions assn/gmane/peer2.json
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"title":"Mailing List Data - Part II",
"description":"In this assignment you will visualize the mailing list data you have downloaded from http://mbox.dr-chuck.net/ and take some screen shots. Important: You do not have to download all of the data - it is completely acceptible to visualize a small subset of the data for this assignment.",
"grading":"Don't take off points for little mistakes. If they seem to have done the assignment give them full credit. Feel free to make suggestions if there are small mistakes. Please keep your comments positive and useful.",
"solution" : "http://www.dr-chuck.net/pythonlearn/code/gmane.zip",
"parts":[
{
"title":"A screen shot of you running the gbasic.py program to compute basic histogram data on the messages you have retrieved.",
"type":"image"
},
{
"title":"A screen shot of word cloud visualization for the messages you have retrieved.",
"type":"image"
},
{
"title":"A screen shot of time line visualization for the messages you have retrieved.",
"type":"image"
},
{
"title":"Optional Challenge: Change the gline.py program to show the message count by month instead of by year and take a screen shot to the by month visualization. You can switch from a by-year to a by-month visualization by changing only a few lines in gline.js. The puzzle is to figure out the smallest change to accomplish the change. If you do not want to do this optional challenge - just upload the above image a second time. " ,
"type":"image"
}
],
"totalpoints":10,
"instructorpoints":0,
"peerpoints":4,
"assesspoints":2,
"minassess":3,
"maxassess":10,
"flag":true,
"rating":0,
"gallery":"off"
}
33 changes: 33 additions & 0 deletions assn/pagerank/peer.json
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"title":"Page Rank",
"description":"First you will spider 100 pages from http://python-data.dr-chuck.net/ run the page rank algorithm and take some screen shots. Then you will reset the spider process and spider 100 pages from any other site on the Internet, run the page rank alorithm, and take some screen shots.",
"grading":"Don't take off points for little mistakes. If they seem to have done the assignment give them full credit. Feel free to make suggestions if there are small mistakes. Please keep your comments positive and useful.",
"solution" : "http://www.dr-chuck.net/pythonlearn/code/pagerank.zip",
"parts":[
{
"title":"A screen shot of the spdump.py running after you have crawled 100 pages from python-data.dr-chuck.com",
"type":"image"
},
{
"title":"A screen shot of the top 25 pages according to page rank that you crawled from python-data.dr-chuck.com visualized using force.html",
"type":"image"
},
{
"title":"A screen shot of the spdump.py running after you have crawled 100 pages from another web site",
"type":"image"
},
{
"title":"A screen shot of the top 25 pages according to page rank that you crawled from the other web site visualized using force.html",
"type":"image"
}
],
"totalpoints":10,
"instructorpoints":0,
"peerpoints":4,
"assesspoints":2,
"minassess":3,
"maxassess":10,
"flag":true,
"rating":0,
"gallery":"off"
}
8 changes: 6 additions & 2 deletions book/06-strings.mkd
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ start looking. When we slice, we extract the characters from "one beyond
the at-sign through up to *but not including* the space character". the at-sign through up to *but not including* the space character".


The documentation for the `find` method is available at The documentation for the `find` method is available at

<https://docs.python.org/3.5/library/stdtypes.html#string-methods>. <https://docs.python.org/3.5/library/stdtypes.html#string-methods>.


Format operator Format operator
Expand Down Expand Up @@ -624,6 +625,7 @@ element is the wrong type.


The format operator is powerful, but it can be difficult to use. You can The format operator is powerful, but it can be difficult to use. You can
read more about it at read more about it at

<https://docs.python.org/3.5/library/stdtypes.html#printf-style-string-formatting>. <https://docs.python.org/3.5/library/stdtypes.html#printf-style-string-formatting>.


Debugging Debugging
Expand Down Expand Up @@ -777,8 +779,10 @@ Exercise 6:
\index{method!string} \index{method!string}


Read the documentation of the string methods at Read the documentation of the string methods at
<https://docs.python.org/3.5/library/stdtypes.html#string-methods>. You
might want to experiment with some of them to make sure you understand <https://docs.python.org/3.5/library/stdtypes.html#string-methods>

You might want to experiment with some of them to make sure you understand
how they work. `strip` and `replace` are how they work. `strip` and `replace` are
particularly useful. particularly useful.


Expand Down
12 changes: 8 additions & 4 deletions book/07-files.mkd
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ individuals in an open source project development team:
`...` `...`


The entire file of mail interactions is available from The entire file of mail interactions is available from
[www.pythonlearn.com/code3/mbox.txt](http://www.pythonlearn.com/code3/mbox.txt) and a
shortened version of the file is available from [www.pythonlearn.com/code3/mbox.txt](http://www.pythonlearn.com/code3/mbox.txt)
[www.pythonlearn.com/code3/mbox-short.txt](http://www.pythonlearn.com/code3/mbox-short.txt).
and a shortened version of the file is available from

[www.pythonlearn.com/code3/mbox-short.txt](http://www.pythonlearn.com/code3/mbox-short.txt)

These files are in a standard format for a file containing multiple mail These files are in a standard format for a file containing multiple mail
messages. The lines which start with "From " separate the messages and messages. The lines which start with "From " separate the messages and
the lines which start with "From:" are part of the messages. For more the lines which start with "From:" are part of the messages. For more
Expand Down Expand Up @@ -563,6 +567,7 @@ program will look as follows:
SAT, 05 JAN 2008 09:14:16 -0500 SAT, 05 JAN 2008 09:14:16 -0500


You can download the file from You can download the file from

[www.pythonlearn.com/code3/mbox-short.txt](http://www.pythonlearn.com/code3/mbox-short.txt) [www.pythonlearn.com/code3/mbox-short.txt](http://www.pythonlearn.com/code3/mbox-short.txt)


Exercise 2: Write a program to prompt for a file name, and then read Exercise 2: Write a program to prompt for a file name, and then read
Expand All @@ -587,7 +592,6 @@ Test your file on the `mbox.txt` and


Exercise 3: Sometimes when programmers get bored or want to have a bit Exercise 3: Sometimes when programmers get bored or want to have a bit
of fun, they add a harmless *Easter Egg* to their program of fun, they add a harmless *Easter Egg* to their program
([en.wikipedia.org/wiki/Easter\_egg\_(media)](en.wikipedia.org/wiki/Easter_egg_(media))).
Modify the program that prompts the user for the file name so that it Modify the program that prompts the user for the file name so that it
prints a funny message when the user types in the exact file name "na na prints a funny message when the user types in the exact file name "na na
boo boo". The program should behave normally for all other files which boo boo". The program should behave normally for all other files which
Expand Down
3 changes: 1 addition & 2 deletions book/12-network.mkd
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ Attrs: [('href', 'http://www.dr-chuck.com/page2.htm')]
~~~~ ~~~~


These examples only begin to show the power of BeautifulSoup when it These examples only begin to show the power of BeautifulSoup when it
comes to parsing HTML. See the documentation and samples at comes to parsing HTML.
<http://www.crummy.com/software/BeautifulSoup/> for more detail.


Reading binary files using urllib Reading binary files using urllib
--------------------------------- ---------------------------------
Expand Down
2 changes: 1 addition & 1 deletion book/13-web.mkd
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ You can read the online documentation for this service, but it is quite
simple and you can even test it using a browser by typing the following simple and you can even test it using a browser by typing the following
URL into your browser: URL into your browser:


[http://maps.googleapis.com/maps/api/geocode/json?sensor=false &address=Ann+Arbor%2C+MI](http://maps.googleapis.com/maps/api/geocode/json?sensor=false &address=Ann+Arbor%2C+MI) [http://maps.googleapis.com/maps/api/geocode/json?address=Ann+Arbor%2C+MI](http://maps.googleapis.com/maps/api/geocode/json?address=Ann+Arbor%2C+MI)


Make sure to unwrap the URL and remove any spaces from the URL before Make sure to unwrap the URL and remove any spaces from the URL before
pasting it into your browser. pasting it into your browser.
Expand Down
11 changes: 5 additions & 6 deletions book/A0-preface.mkd
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
Credits Credits
------- -------


Illustrations: TBD Editorial Support: Elliott Hauser, Sue Blumenberg
Editorial Support: TBD Cover Design: Aimee Andrion
Cover Design: TBD


Printing History Printing History
---------------- ----------------
Expand All @@ -23,7 +22,7 @@ While the book is being edited and reviewed, it
is temporarily Copyright All Rights is temporarily Copyright All Rights
Reserved Charles R. Severance 2015 - Reserved Charles R. Severance 2015 -


When the book is completed in early 2016, When the book is completed in 2016,
it will be released under CC-BY it will be released under CC-BY
like all my open books. I just don't want like all my open books. I just don't want
anyone grabbing this and publishing it anyone grabbing this and publishing it
Expand All @@ -43,8 +42,8 @@ will be acknowledged in the published book.
Preface Preface
======= =======


Python for Informatics: Remixing an Open Book Remixing an Open Book
--------------------------------------------- ---------------------


It is quite natural for academics who are continuously told to "publish It is quite natural for academics who are continuously told to "publish
or perish" to want to always create something from scratch that is their or perish" to want to always create something from scratch that is their
Expand Down
1 change: 1 addition & 0 deletions book/AD-copyright.mkd
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Copyright Detail
This work is licensed under a Creative Common This work is licensed under a Creative Common
Attribution-NonCommercial-ShareAlike 3.0 Unported License. This license Attribution-NonCommercial-ShareAlike 3.0 Unported License. This license
is available at is available at

[creativecommons.org/licenses/by-nc-sa/3.0/](creativecommons.org/licenses/by-nc-sa/3.0/). [creativecommons.org/licenses/by-nc-sa/3.0/](creativecommons.org/licenses/by-nc-sa/3.0/).


I would have preferred to license the book under the less restrictive I would have preferred to license the book under the less restrictive
Expand Down
2 changes: 1 addition & 1 deletion code/re03.py
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
# Search for lines that start with From and have an at sign # Search for lines that start with F and have an at sign
import re import re
hand = open('mbox-short.txt') hand = open('mbox-short.txt')
for line in hand: for line in hand:
Expand Down
2 changes: 1 addition & 1 deletion code/re05.py
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
import re import re
s = 'Hello this is a message from csev@umich.edu to cwen@iupui.edu about the meeting @2PM' s = 'This message from csev@umich.edu to cwen@iupui.edu is about a meeting @2PM'
lst = re.findall('\S+@\S+', s) lst = re.findall('\S+@\S+', s)
print lst print lst


1 change: 0 additions & 1 deletion code/re10.py
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,3 @@
# Search for lines that start with From and have an at sign
import re import re
hand = open('mbox-short.txt') hand = open('mbox-short.txt')
for line in hand: for line in hand:
Expand Down
4 changes: 3 additions & 1 deletion code3/geojson.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
address = input('Enter location: ') address = input('Enter location: ')
if len(address) < 1 : break if len(address) < 1 : break


url = serviceurl + urllib.parse.urlencode({'sensor':'false', 'address': address}) url = serviceurl + urllib.parse.urlencode(
{'sensor':'false', 'address': address})

print('Retrieving', url) print('Retrieving', url)
uh = urllib.request.urlopen(url) uh = urllib.request.urlopen(url)
data = uh.read().decode() data = uh.read().decode()
Expand Down
3 changes: 2 additions & 1 deletion code3/re03.py
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,5 @@
# Search for lines that start with 'F', followed by 2 characters, followed by 'm:' # Search for lines that start with 'F', followed by
# 2 characters, followed by 'm:'
import re import re
hand = open('mbox-short.txt') hand = open('mbox-short.txt')
for line in hand: for line in hand:
Expand Down
2 changes: 1 addition & 1 deletion code3/re05.py
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
import re import re
s = 'Hello this is a message from csev@umich.edu to cwen@iupui.edu about the meeting @2PM' s = 'A message from csev@umich.edu to cwen@iupui.edu about meeting @2PM'
lst = re.findall('\S+@\S+', s) lst = re.findall('\S+@\S+', s)
print(lst) print(lst)


6 changes: 4 additions & 2 deletions code3/re10.py
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,7 @@
# Search for lines that start with 'X' followed by any non whitespace characters and ':' # Search for lines that start with 'X' followed by any non
# followed by a space and any number. The number can include a decimal. # whitespace characters and ':'
# followed by a space and any number.
# The number can include a decimal.
import re import re
hand = open('mbox-short.txt') hand = open('mbox-short.txt')
for line in hand: for line in hand:
Expand Down
5 changes: 3 additions & 2 deletions code3/re11.py
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,6 @@
# Search for lines that start with 'X' followed by any non whitespace characters and ':' # Search for lines that start with 'X' followed by any
# followed by a space and any number. The number can include a decimal. # non whitespace characters and ':' followed by a space
# and any number. The number can include a decimal.
# Then print the number if it is greater than zero. # Then print the number if it is greater than zero.
import re import re
hand = open('mbox-short.txt') hand = open('mbox-short.txt')
Expand Down
3 changes: 2 additions & 1 deletion code3/re12.py
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,5 @@
# Search for lines that start with 'Details: rev=' followed by numbers and '.' # Search for lines that start with 'Details: rev='
# followed by numbers and '.'
# Then print the number if it is greater than zero # Then print the number if it is greater than zero
import re import re
hand = open('mbox-short.txt') hand = open('mbox-short.txt')
Expand Down
3 changes: 2 additions & 1 deletion code3/re13.py
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,5 @@
# Search for lines that start with From and a character followed by a two digit number between 00 and 99 followed by ':' # Search for lines that start with From and a character
# followed by a two digit number between 00 and 99 followed by ':'
# Then print the number if it is greater than zero # Then print the number if it is greater than zero
import re import re
hand = open('mbox-short.txt') hand = open('mbox-short.txt')
Expand Down
3 changes: 2 additions & 1 deletion code3/socket1.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@


mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('www.pythonlearn.com', 80)) mysock.connect(('www.pythonlearn.com', 80))
mysock.send('GET http://www.pythonlearn.com/code3/romeo.txt HTTP/1.0\n\n'.encode()) cmd = 'GET http://www.pythonlearn.com/code3/romeo.txt HTTP/1.0\n\n'.encode()
mysock.send(cmd);


while True: while True:
data = mysock.recv(512) data = mysock.recv(512)
Expand Down
10 changes: 5 additions & 5 deletions code3/twfriends.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
acct = input('Enter a Twitter account, or quit: ') acct = input('Enter a Twitter account, or quit: ')
if ( acct == 'quit' ) : break if ( acct == 'quit' ) : break
if ( len(acct) < 1 ) : if ( len(acct) < 1 ) :
cur.execute('SELECT id, name FROM People WHERE retrieved = 0 LIMIT 1') cur.execute('SELECT id,name FROM People WHERE retrieved = 0 LIMIT 1')
try: try:
(id, acct) = cur.fetchone() (id, acct) = cur.fetchone()
except: except:
Expand All @@ -29,8 +29,8 @@
try: try:
id = cur.fetchone()[0] id = cur.fetchone()[0]
except: except:
cur.execute('INSERT OR IGNORE INTO People (name, retrieved) VALUES ( ?, 0)', cur.execute('''INSERT OR IGNORE INTO People
( acct, ) ) (name, retrieved) VALUES ( ?, 0)''', ( acct, ) )
conn.commit() conn.commit()
if cur.rowcount != 1 : if cur.rowcount != 1 :
print('Error inserting account:',acct) print('Error inserting account:',acct)
Expand Down Expand Up @@ -69,8 +69,8 @@
continue continue
friend_id = cur.lastrowid friend_id = cur.lastrowid
countnew = countnew + 1 countnew = countnew + 1
cur.execute('INSERT OR IGNORE INTO Follows (from_id, to_id) VALUES (?, ?)', cur.execute('''INSERT OR IGNORE INTO Follows (from_id, to_id)
(id, friend_id) ) VALUES (?, ?)''', (id, friend_id) )
print('New accounts=',countnew,' revisited=',countold) print('New accounts=',countnew,' revisited=',countold)
conn.commit() conn.commit()


Expand Down
3 changes: 2 additions & 1 deletion code3/twspider.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
cur = conn.cursor() cur = conn.cursor()


cur.execute(''' cur.execute('''
CREATE TABLE IF NOT EXISTS Twitter (name TEXT, retrieved INTEGER, friends INTEGER)''') CREATE TABLE IF NOT EXISTS Twitter
(name TEXT, retrieved INTEGER, friends INTEGER)''')


while True: while True:
acct = input('Enter a Twitter account, or quit: ') acct = input('Enter a Twitter account, or quit: ')
Expand Down

0 comments on commit 00b4a06

Please sign in to comment.