Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tracks users names

  • Loading branch information...
commit e7cb4db311e0bd0d7903d0fab03c9da968230f29 1 parent 72f8543
Zach Strudler authored
Showing with 13 additions and 3 deletions.
  1. +13 −3 CappParser.py
View
16 CappParser.py
@@ -31,8 +31,10 @@ def __init__(self, prefix):
def parse(file_name, c):
Id = 0
+ Name = ''
data = []
isId = False
+ isName = False
isClass = False
tmpClass = None
classNum = 0
@@ -51,6 +53,9 @@ def parse(file_name, c):
if isId:
Id = int(tags[1])
isId = False
+ elif isName:
+ Name = tags[1]
+ isName = False
elif isClass:
classNum += 1
if classNum == 1: tmpClass.num = int(tags[1])
@@ -68,12 +73,14 @@ def parse(file_name, c):
isClass = True
classNum = 0
except:
- if tags[1] == 'Student ID:':
+ if tags[1] == 'Name:':
+ isName = True
+ elif tags[1] == 'Student ID:':
isId = True
tag = tag+'>'
print 'Parsed: %s' % file_name
- c.execute('insert or ignore into users(id) values (%d)' % Id)
+ c.execute("insert or ignore into users(id, name) values (%d, '%s')" % (Id, Name))
for i in data:
t = (Id, i.prefix, i.num, i.name, i.grade)
c.execute("replace into grades(id, prefix, num, name, grade) values (%d, '%s', %d, '%s', '%s')" % t)
@@ -90,7 +97,10 @@ def run():
db = sqlite3.connect('grades.sqlite')
c = db.cursor()
- c.execute('create table if not exists users(id integer primary key)')
+ c.execute('''create table if not exists users(
+ id integer primary key,
+ name varchar
+ )''')
c.execute('''create table if not exists grades(
id integer,
prefix varchar,
Please sign in to comment.
Something went wrong with that request. Please try again.