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 | |
#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() |
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
# 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' |
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
# 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 | |
# http://www.dr-chuck.com/page1.htm | |
# Week 4 Assignment Sample is defined | |
# Author Don lovett Based on Code from Using Python to Access Web Data text by Charles Severance | |
import re | |
import urllib | |
from BeautifulSoup import * |
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
# Search for lines that have numbers with a regular expression, add to an array, convert to integers and count and sum | |
# Author Don lovett Based on Code from Using Python to Access Web Data text by Charles Severance | |
import re | |
#fname = raw_input('Enter file:') Use for prompted file name | |
#hand = open(fname) | |
hand = open("/home/vagrant/Coursera/Week2/regex_sum_318168.txt") | |
nums = list() | |
z = 0 | |
for line in hand: | |
line = line.rstrip() |
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
# Search for lines that start with From and have an at sign | |
import re | |
#fname = raw_input('Enter file:') | |
#hand = open(fname) | |
hand = open("/home/vagrant/Coursera/Week2/regex_sum_318168.txt") | |
nums = list() | |
z = 0 | |
for line in hand: | |
line = line.rstrip() | |
x = re.findall('([0-9]+)', line) |
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
/** | |
* Created by don on 11/22/2015. | |
*/ | |
println "Hello World This is my first test" | |
def x = 42 | |
println x.getClass() | |
x = "Hello World" | |
println x.getClass() |
NewerOlder