-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a12855
commit 4435dc5
Showing
7 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><sqlb_project><db path="/Users/rkim/Documents/UT/CS/BTHO-TAMU-Registration/initial.db" foreign_keys="1"/><window><current_tab id="1"/></window><tab_structure><column_width id="0" width="300"/><column_width id="1" width="0"/><column_width id="2" width="100"/><column_width id="3" width="880"/><expanded_item id="0" parent="1"/><expanded_item id="0" parent="0"/><expanded_item id="1" parent="0"/><expanded_item id="1" parent="1"/><expanded_item id="2" parent="1"/><expanded_item id="3" parent="1"/></tab_structure><tab_browse><current_table name="agg"/><default_encoding codec=""/><browsetable_info data="AAAAAgAAABQAcwBlAG0AXwBnAHIAYQBkAGUAcwAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////AAAAAP////8AAAAGAGEAZwBnAAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////8AAAAA/////w=="/></tab_browse><tab_sql><sql name="SQL 1">INSERT INTO aggregate | ||
SELECT prof, | ||
dept, | ||
course_nbr, | ||
course_name, | ||
SUM(a), SUM(b), SUM(c), SUM(d), SUM(f), SUM(totalAF) | ||
FROM section_grades | ||
GROUP BY prof, dept, course_nbr, course_name | ||
</sql><sql name="SQL 1"></sql><current_tab id="1"/></tab_sql></sqlb_project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import sqlite3 | ||
con3 = sqlite3.connect("db1.db") | ||
|
||
con3.execute("ATTACH 'db2.db' as db2") | ||
|
||
con3.execute("BEGIN") | ||
for row in con3.execute("SELECT * FROM db2.sqlite_master WHERE type='table'"): | ||
combine = "INSERT INTO "+ row[1] + " SELECT * FROM db2." + row[1] | ||
print(combine) | ||
con3.execute(combine) | ||
con3.commit() | ||
con3.execute("detach database db2") |
Binary file not shown.
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import scraperwiki | ||
import sqlite3 | ||
from bs4 import BeautifulSoup | ||
import string | ||
import unicodedata | ||
import time | ||
import requests | ||
import json | ||
|
||
headers = ["Name","Department","Total Ratings","Overall Quality","Easiness","Hot"] | ||
#Dictionary of school ids (keys) that map to tuple of school name and number of pages | ||
colleges = {"1003":("Texas A&M",4)} | ||
|
||
for sid in colleges.keys(): | ||
college,pages = colleges[sid] | ||
print college | ||
for i in xrange(1,pages+1): | ||
response = scraperwiki.scrape("http://www.ratemyprofessors.com/SelectTeacher.jsp?sid=%s&pageNo=%s" % (sid,str(i))) | ||
xxxx = requests.get("http://www.ratemyprofessors.com/SelectTeacher.jsp?sid=%s&pageNo=%s" % (sid,str(i))) | ||
print(xxxx.text) | ||
print("http://www.ratemyprofessors.com/SelectTeacher.jsp?sid=%s&pageNo=%s" % (sid,str(i))) | ||
time.sleep(5) | ||
soup = BeautifulSoup(response) | ||
rows = soup.find_all("div",{"class":"entry odd vertical-center"}) | ||
rows.extend(soup.find_all("div",{"class":"entry even vertical-center"})) | ||
for row in rows: | ||
columns = row.find_all('div') | ||
columns = columns[3:] | ||
variables = {} | ||
for i,col in enumerate(columns): | ||
value = unicodedata.normalize('NFKD', col.text).encode('ascii', 'ignore') | ||
variables[headers[i]] = value | ||
variables["College"] = college | ||
scraperwiki.sqlite.save(unique_keys=['Name',"Department"], data = variables) | ||
print(variables) |