Beispiel #1
0
def get_coach_data(filename):
    try:
        with open(filename) as f:
            data = f.readline()
            listData = data.strip().split(',')
            return Athlete(listData.pop(0), listData.pop(0), listData)
    except IOError as ioerr:
        print('File error: ' + str(ioerr))
        return (None)
import sqlite3
import glob
from athletemodel import Athlete

connection = sqlite3.connect('coachdata.sqlite')
cursor = connection.cursor()


athletes = []
data_files = glob.glob("../data/*.txt")
for each_file in data_files:
	athlete = Athlete()
	athlete.loaddatabyfile(each_file)
	athletes.append(athlete)

for each_ath in athletes:
    name = each_ath.name
    dob = each_ath.birthdate
    cursor.execute("INSERT INTO athletes (name, dob) VALUES (?, ?)", (name, dob))
    connection.commit()

connection.close()
Beispiel #3
0
#! /usr/bin/python3

# Step 2: write a new CGI script to handle the new data request.
import json
import glob
import yate
import cgi
import athletemodel
from athletemodel import Athlete

		
athletes = []
data_files = glob.glob("data/*.txt")
for each_file in data_files:
	athlete = Athlete()
	athlete.loaddatabyfile(each_file)
	athletes.append(athlete)

form_data = cgi.FieldStorage()
athelete_name = form_data['which_athlete'].value

#athelete_name = 'James Lee'

#print("athelete name:", athelete_name)

athlete = None
for each_athlete in athletes:
	#print(each_athlete.name)
	if athelete_name == each_athlete.name:
		athlete = each_athlete
	else: