コード例 #1
0
def plotScatterPlot(Tosend):
    try:
        Val_1 = "Populating Scatter Plot for the countries after values are fetched"
        DB.InsertLogs(Val_1)
        x = Tosend.keys()
        y = Tosend.values()

        fig, ax = plt.subplots()
        ax.set_facecolor("#fffac8")
        ax.scatter(y,
                   x,
                   color='#800000',
                   s=10,
                   edgecolors='black',
                   linewidths=10)

        plt.xlabel("Count")
        #plt.ylabel("")
        plt.xlim(0, 2000)
        ax.grid(True)
        #ax.set_ylim(width=10, len=200)
        plt.title("Players Distribution based on Nationality")
        fig.show()
    except Exception as e:
        DB.InsertExceptionStmtTable(e, "Nationality - plotScatterPlot")
コード例 #2
0
def GenerateClubs():
    try:

        Val_1 = "Fetching Records from the list"
        DB.InsertLogs(Val_1)

        Players_Data = ER.extractRecords()
        for i in range(0, len(Players_Data)):
            Distinct_Club.append(Players_Data[i][8])

        Val_1 = "Fetching Records from the list completed"
        DB.InsertLogs(Val_1)

        #Delete Duplicates
        Distinct_Club_Final = set(Distinct_Club)
        print(len(Distinct_Club_Final))
        Distinct_Club_Final = list(sorted(Distinct_Club_Final))

        #Remove Null Value
        del Distinct_Club_Final[0]

        Val_1 = "Returning Distinct Club Values"
        DB.InsertLogs(Val_1)

        return Distinct_Club_Final
    except Exception as e:
        DB.InsertExceptionStmtTable(e, "Compare Two Teams - GenerateClubs")
コード例 #3
0
def removeFunction(x):
    print("Remove")
    try:
        Val_1 = "Generating Scatter Plot"
        DB.InsertLogs(Val_1)
        if select1.size() == 0:
            tkinter.messagebox.showinfo("Error", "Nothing to Remove")
            DB.InsertExceptionStmtTable("Nothing to Remove",
                                        "Nationality - removeFunction")
        else:
            if x == 1:
                #print(select1.curselection())
                a = select1.curselection()
                print("Remove", a)
                print("Replacing")
                #a = str(a).replace(",","")
                print("After", a)
                select1.delete(a, END)
            elif x == 2:

                select1.delete(0, END)
            else:
                print("Error")

    except Exception as e:
        tkinter.messagebox.showinfo("Error", e)
        DB.InsertExceptionStmtTable(e, "Nationality - removeFunction")
コード例 #4
0
def GenerateScatterPlotDict():
    try:
        Val_1 = "Populating Scatter Plot for the countries after validations"
        DB.InsertLogs(Val_1)
        if select1.size() == 0:
            tkinter.messagebox.showinfo(
                "Error",
                "Add Atleast one or more Countries to view Scatter Plot")
            DB.InsertExceptionStmtTable(
                "Add Atleast one or more Countries to view Scatter Plot",
                "Nationality - removeFunction")
        else:
            Tosend = {}
            print("Here1")
            #ND.Nationality_Selection()
            Final_Count = ND.Nationality_Selection()
            #print(Final_Count)
            #print("Generating")
            #print(Final_Count)
            print(select1.size())

            #For each of the countries go in a for loop and update the value
            for i in range(0, select1.size()):
                country = select1.get(i)
                #print("Country Name",country[0])
                #print(Final_Count[country[0]])
                Tosend.update({country[0]: Final_Count[country[0]]})

            #After the for loop send the values to generate Scatter plot
            plotScatterPlot(Tosend)
    except Exception as e:
        DB.InsertExceptionStmtTable(e, "Nationality - GenerateScatterPlotDict")
コード例 #5
0
def OpenDBandGenerate(Final_Val, DynamicSQL):
    try:
        print("Passing here")
        Val_1 = "Generating SQL Records"
        DB.InsertLogs(Val_1)
        conn = DB.OpenConnection()
        c = conn.cursor()
        c.execute(DynamicSQL)
        rows = c.fetchall()
        print("length is", len(rows))
        if len(rows) == 0:
            tkinter.messagebox.showinfo("No Records",
                                        "No Records avaiable for this search")
            DB.InsertExceptionStmtTable("No Records avaiable for this search",
                                        "Generate Report - OpenDBandGenerate")
        else:
            Val_1 = "Writing Records"
            DB.InsertLogs(Val_1)
            with open(Final_Val, "w", encoding='utf-8', newline='') as f:
                writer = csv.writer(f, lineterminator='\n')
                writer.writerow(ColValues)
                for row in rows:
                    print(str(list(row)))
                    writer.writerow(list(row))
    except Exception as e:
        print(e)
        DB.InsertExceptionStmtTable(e, "Generate Report - OpenDBandGenerate")
コード例 #6
0
def RegisterUser(finame, Conpwd, pwd, Number, emailname):
    Pass_1 = hashlib.md5(pwd.encode())
    Pass_1 = Pass_1.hexdigest()
    print(Pass_1)
    Con_Pass = hashlib.md5(pwd.encode())
    Con_Pass = Con_Pass.hexdigest()
    print(Con_Pass)
    try:
        Val_1 = "Open DB and Create Login"
        DB.InsertLogs(Val_1)
        conn = DB.OpenConnection()
        c = conn.cursor()
        c.execute(DB.InsertLoginTableStmt,
                  (str(finame), str(Pass_1), str(Con_Pass), str(emailname),
                   Number, 'Y'))
        conn.commit()
        tkinter.messagebox.showinfo(
            "Success",
            "Login has been created. Proceed to Login page to View FIFA 18 Data Visualizations "
        )
        root.destroy()

    except Exception as e:
        print(e)
        tkinter.messagebox.showinfo("Error", e)
        DB.InsertExceptionStmtTable(e, "Registration - RegisterUser")
コード例 #7
0
def setList():
    try:
        Val_1 = "Populating Players Name from DB"
        DB.InsertLogs(Val_1)
        print("Generate")
        conn = DB.OpenConnection()
        c = conn.cursor()
        c.execute("SELECT NAME FROM AC_FIFA18_READ_DATA;")
        select.delete(0, END)
        for name in c.fetchall():
            select.insert(END, name)
    except Exception as e:
        DB.InsertExceptionStmtTable(e, "Players_Compare - setList")
コード例 #8
0
def LoadPlayer2():
    try:
        Val_1 = "Load player 2 data and Validate"
        DB.InsertLogs(Val_1)
        a = select.curselection()
        if a == ():
            tkinter.messagebox.showinfo("Error", "Choose a Player")
            DB.InsertExceptionStmtTable("Player_2 Empty",
                                        "Players_Compare - LoadPlayer2")
        else:
            Player2_Var.set(select.get(ACTIVE))
    except Exception as e:
        tkinter.messagebox.showinfo("Error", e)
        DB.InsertExceptionStmtTable(e, "Players_Compare - LoadPlayer2")
コード例 #9
0
def setList(Distinct_Club_Final):
    try:
        Val_1 = "Insert Club Names into Listbox"
        DB.InsertLogs(Val_1)

        print("Generate")
        select.delete(0, END)
        for i in Distinct_Club_Final:
            select.insert(END, i)

        print("setList  Size", len(Distinct_Club_Final))
        return Distinct_Club_Final
    except Exception as e:
        DB.InsertExceptionStmtTable(e, "Compare Two Teams - GenerateClubs")
コード例 #10
0
def createSquad():
    try:

        ##Log Statement
        Val_1 = "Formation Selection-2"
        DB.InsertLogs(Val_1)

        if FormationVar.get() == "":
            tkinter.messagebox.showinfo(
                "Error", "Select a formation to generate Your Squad")
            DB.InsertExceptionStmtTable(
                e, "Best Team - AddFormation - No formation selected-2")
        else:
            try:

                ##Log Statement
                Val_1 = "Opening Connection for formation details"
                DB.InsertLogs(Val_1)

                conn = DB.OpenConnection()
                c = conn.cursor()
                b = FormationVar.get()
                b = ((b.replace(',', '')).replace('(', '')).replace(')', '')
                print(b)
                sql = 'SELECT Defenders,Midfielders,Attackers FROM AC_FIFA18_FORMATIONS Where Formation = ' + str(
                    b)
                c.execute(sql)

                squad = [
                ]  # Insert how many defenders/Midfielders/Attackers necessary for the foramation
                for i in c.fetchone():
                    squad.append(i)

                #Log Statement
                Val_1 = "Squad details fetched"
                DB.InsertLogs(Val_1)

                print(len(squad))
                print("squad is ", squad)
                Def = squad[0]  #Defenders
                Mid = squad[1]  #Midfielders
                Att = squad[2]  #Attackers

                #Pass on the above details to generate Players Llist
                Val_1 = "Generate Squad"
                DB.InsertLogs(Val_1)

                generateSquad(Def, Mid, Att)

            except Exception as e:
                print(e)
                DB.InsertExceptionStmtTable(e, "Best Team - CreateSquad")
    except Exception as ae:
        print(ae)
        DB.InsertExceptionStmtTable(ae,
                                    "Best Team- CreateSquad Outer Exception")
コード例 #11
0
ファイル: WC.py プロジェクト: cananthc/Python_Final_Project
def GenerateWordCloud():
    try:
        Val_1 = "Word Cloud image started"
        DB.InsertLogs(Val_1)

        file_content = open("Exception.txt").read()

        wordcloud = WordCloud(stopwords=STOPWORDS,
                              background_color='white',
                              width=1200,
                              height=1000).generate(file_content)

        plt.imshow(wordcloud)
        plt.axis('off')
        plt.show()
    except Exception as e:
        DB.InsertExceptionStmtTable(e, "WC - GenerateWordCloud")
コード例 #12
0
def setList():
    try:
        Val_1 = "Extracting Nationality "
        DB.InsertLogs(Val_1)
        conn = DB.OpenConnection()
        cur = conn.cursor()
        cur.execute('SELECT * FROM AC_FIFA18_COUNTRIES ORDER BY 1 ')
        select.delete(0, END)
        for name in cur.fetchall():
            #temp=[name,count]
            #countries.append(temp)
            select.insert(END, name)
        #print(countries)
        Val_1 = "Extracting Nationality Completed"
        DB.InsertLogs(Val_1)

    except Exception as e:
        DB.InsertExceptionStmtTable(e, "Nationality - setList")
コード例 #13
0
def AddFormation():
    try:
        ##Log Statement
        Val_1 = "Formation Selection"
        DB.InsertLogs(Val_1)

        a = select.curselection()
        print("Pass")
        if select.curselection() == ():
            tkinter.messagebox.showinfo("Error", "Select a formation")
            DB.InsertExceptionStmtTable(
                e, "Best Team - AddFormation - No formation selected")
        else:
            FormationVar.set(select.get(ACTIVE))

    except Exception as e:
        print("Error", e)
        DB.InsertExceptionStmtTable(e, "Best Team- AddFormation")
コード例 #14
0
def loadFunction(x):
    try:
        Val_1 = "Loading Selected Country based on the parameter"
        DB.InsertLogs(Val_1)
        #a = select.curselection()
        #print("Value is ",a)
        c = select.curselection()
        print(c)
        print("Pass")
        print("C Value ", c)
        print("Select Value", select1.get(0, END))
        if c == ():
            if x == 2:
                conn = DB.OpenConnection()
                cur = conn.cursor()
                cur.execute('SELECT * FROM AC_FIFA18_COUNTRIES ORDER BY 1 ')
                for name in cur.fetchall():
                    select1.insert(END, name)
            else:
                tkinter.messagebox.showinfo("Error",
                                            "You haven't Selected Any!")
                DB.InsertExceptionStmtTable("You haven't Selected Any team!",
                                            "Nationality - loadFunction")
        else:
            c = select.get(ACTIVE)
            print(c)
            if c in select1.get(0, END):
                tkinter.messagebox.showinfo(
                    "Error", "Duplicate Value Cannot be inserted")
                DB.InsertExceptionStmtTable(
                    "Duplicate Value Cannot be inserted",
                    "Nationality - loadFunction")
            else:
                if x == 1:
                    print("Can Add")
                    print(select.curselection())
                    a = select.get(ACTIVE)
                    select1.insert(END, a)
                else:
                    print("Error")

    except Exception as e:
        tkinter.messagebox.showinfo("Error", e)
        DB.InsertExceptionStmtTable(e, "Nationality - loadFunction")
コード例 #15
0
def LoadTeam2():
    try:
        Val_1 = "inserting Team_2"
        DB.InsertLogs(Val_1)

        Distinct_Club_Final = GenerateClubs()
        print("Team2", len(Distinct_Club_Final))
        print(select.curselection())
        a = select.curselection()
        a = str(a).replace(',', '').replace(')', '').replace('(', '')
        print(a)
        teamName2 = str(Distinct_Club_Final[int(a)])
        Teamname2Var.set(teamName2)

        Val_1 = "insertion Completed Team_2"
        DB.InsertLogs(Val_1)
    except Exception as e:
        tkinter.messagebox.showinfo("Error", "Select a Team !!")
        DB.InsertExceptionStmtTable(e, "Compare Two Teams - LoadTeam2")
コード例 #16
0
ファイル: WC.py プロジェクト: cananthc/Python_Final_Project
def GenerateExceptionFile():
    try:
        Val_1 = "Opening connection to write the exception"
        DB.InsertLogs(Val_1)
        conn = DB.OpenConnection()
        c = conn.cursor()
        c.execute("SELECT * FROM AC_FIFA18_EXCEPTION;")
        rows = c.fetchall()
        Val_1 = "Writing Records"
        DB.InsertLogs(Val_1)
        with open("Exception.txt", "a", encoding='utf-8', newline='') as f:
            writer = csv.writer(f, lineterminator='\n')
            for row in rows:
                #print(str(list(row)))
                writer.writerow(list(row))
        Val_1 = "Records are appended to the existing file"
        DB.InsertLogs(Val_1)
        GenerateWordCloud()
    except Exception as e:
        DB.InsertExceptionStmtTable(e, "WC - GenerateExceptionFile")
コード例 #17
0
def extractColumnNames():
    try:
        Val_1 = "Extract Columns"
        DB.InsertLogs(Val_1)
        data = []
        print("Executing Extract Records")
        with open(Source_Data, "r", encoding="utf8") as DataSet:
            printData = csv.reader(DataSet, delimiter=' ')
            for row in printData:
                data.append(row)
            print(data[0])

            #Splitting ColNames into a seperate list
            for x in data[0]:
                x = x.split(",")
                ColNames.append(x)
        return ColNames
        Val_1 = "Extract Columns Completed"
        DB.InsertLogs(Val_1)
    except Exception as e:
        DB.InsertExceptionStmtTable(e, "Extract Records - extractColumnNames")
コード例 #18
0
def setList():
    try:
        ##Log Statement
        Val_1 = "Started Fetching Formation from DB"
        DB.InsertLogs(Val_1)

        print("Generate")
        #print(Condition)
        conn = DB.OpenConnection()
        c = conn.cursor()
        c.execute('SELECT FORMATION FROM AC_FIFA18_FORMATIONS')
        select.delete(0, END)
        for i in c.fetchall():
            select.insert(END, i)

        ##Log Statement
        Val_1 = "Completed Inserting Formation "
        DB.InsertLogs(Val_1)

    except Exception as e:
        DB.InsertExceptionStmtTable(e, "Best Team - setList")
コード例 #19
0
def clearTeam(x):
    try:

        if x == 1:
            if Teamname1Var.get() == "":
                tkinter.messagebox.showinfo("Error", "Nothing To Remove!")
                DB.InsertExceptionStmtTable(
                    "Nothing To Remove!", "Comapare Two  Teams - clearTeam1")
            else:
                Teamname1Var.set("")

        else:
            if Teamname2Var.get() == "":
                tkinter.messagebox.showinfo("Error", "Nothing To Remove!")
                DB.InsertExceptionStmtTable(
                    "Nothing To Remove!", "Comapare Two  Teams - clearTeam2")
            else:
                Teamname2Var.set("")
    except Exception as e:
        print("Error", e)
        DB.InsertExceptionStmtTable(ae, "Comapare Two  Teams - clearTeam")
コード例 #20
0
def buildFrame():  #Application interface
    Val_1 = "Generating GUI"
    DB.InsertLogs(Val_1)

    global username, passvar, root, UserLabel
    root = Tk()
    root.title('Fifa18 Data Visualization')
    root.resizable(width=FALSE, height=FALSE)
    root.geometry('1000x650')

    GUIFrame = Frame(root)
    GUIFrame.pack(side=TOP)

    #Heading
    Heading = Label(
        GUIFrame, text="Welcome To FIFA 18 Data Visualization").grid(row=0,
                                                                     column=1)

    #Email Id
    UserLabel = Label(GUIFrame, text="Email_Id:").grid(row=4,
                                                       column=0,
                                                       sticky=W,
                                                       pady=10)
    username = StringVar(GUIFrame)
    name = Entry(GUIFrame, textvariable=username)
    name.grid(row=4, column=1, sticky=W, pady=10)

    #Password
    PasswordLabel = Label(GUIFrame, text="Password:"******" Login  ",
                      command=lambda: login_Validate(username, passvar)).grid(
                          row=6, column=0)

    ##Sign up button
    Signupbtn = Button(GUIFrame, text=" Sign Up!", command=RS.registration)
    Signupbtn.grid(row=6, column=1)

    ##Exit Button
    Exitbtn = Button(GUIFrame, text=" Exit ", width=7, command=exit)
    Exitbtn.grid(row=6, column=2)

    return root
コード例 #21
0
def registration():
    Val_1 = "Opening Registration GUI"
    DB.InsertLogs(Val_1)
    global finame, Conpwd, pwd, Number, emailname, root
    root = Tk()
    root.title('Registration Page')
    root.resizable(width=FALSE, height=FALSE)
    root.geometry('400x400')

    GUIFrame = Frame(root)  # add a row of buttons
    GUIFrame.grid(row=20, column=20)

    Heading = Label(GUIFrame,
                    text="Welcome To FIFA 18 Registration Page").grid(row=0,
                                                                      column=2)

    #Name
    FnameLabel = Label(GUIFrame, text="First Name").grid(row=2, column=1)
    finame = StringVar(GUIFrame)
    fname = Entry(GUIFrame, textvariable=finame).grid(row=2, column=2)

    #Email_id
    Email = Label(GUIFrame, text="Email").grid(row=3, column=1)
    emailname = StringVar(GUIFrame)
    EmailTexbox = Entry(GUIFrame, textvariable=emailname).grid(row=3, column=2)

    #Password
    Password = Label(GUIFrame, text="Password").grid(row=4, column=1)
    pwd = StringVar(GUIFrame)
    password = Entry(GUIFrame, show='*', textvariable=pwd).grid(row=4,
                                                                column=2)

    #Confirm Password
    ConPassword = Label(GUIFrame, text="Confirm Password").grid(row=5,
                                                                column=1)
    Conpwd = StringVar(GUIFrame)
    Conpassword = Entry(GUIFrame, show='*', textvariable=Conpwd).grid(row=5,
                                                                      column=2)

    #Access Code
    NumberLabel = Label(GUIFrame, text="Enter 4 Digit Code").grid(row=6,
                                                                  column=1)
    Number = StringVar(GUIFrame)
    NumberTexbox = Entry(GUIFrame, textvariable=Number).grid(row=6, column=2)

    #Register/Back/Clear
    Registerbut = Button(GUIFrame, text=" Register  ",
                         command=Validations).grid(row=8, column=1)
    BackButton = Button(GUIFrame, text=" Back ").grid(row=8, column=2)
    ClearButton = Button(GUIFrame, text=" Clear ",
                         command=clearButton).grid(row=8, column=3)
コード例 #22
0
def login_Validate(username, passvar):
    Val_1 = "Validating UserName and Password"
    DB.InsertLogs(Val_1)
    if username.get() != "" and passvar.get() != "":
        dbname, dbpass = DB.Uservalidations(username.get(), passvar.get())
        hashpass = hashlib.md5(passvar.get().encode())
        h = hashpass.hexdigest()

        if dbname == username.get() and dbpass == h:
            root.destroy()
            BF.buildFrame()

        else:
            tkinter.messagebox.showinfo(
                "Login- Failed", "Username-Password pair does not exist")
            DB.InsertExceptionStmtTable(
                "Username-Password pair does not exist",
                "Login - login_Validate")
            passvar.set('')
            username.set('')
    else:
        tkinter.messagebox.showinfo("Login- Failed", "Fields Empty")
        DB.InsertExceptionStmtTable("Fields Empty", "Login - login_Validate")
コード例 #23
0
def buildFrame():
    Val_1 = "Opening Best Team Menu"
    DB.InsertLogs(Val_1)
    global FormationVar, Condvar, root, select, GUIFrame
    root = Tk()
    root.title("FIFA 18 Team Selection")
    root.resizable(width=FALSE, height=FALSE)
    root.geometry('1000x650')

    global FormationVar, Condvar
    # Add a grid
    GUIFrame = Frame(root)
    GUIFrame.grid(column=0, row=0, sticky=(N, W, E, S))

    Condvar = StringVar(GUIFrame)

    #Headingx
    Heading = Label(GUIFrame,
                    text="Welcome To FIFA 18 Best Team").grid(row=1, column=5)
    Heading1 = Label(GUIFrame, text="Stats").grid(row=2, column=5)

    DisplayCountryLabel = Label(
        GUIFrame, text="Below are the available Formations").grid(row=3,
                                                                  column=5)
    scroll = Scrollbar(GUIFrame, orient=VERTICAL)
    select = Listbox(GUIFrame, yscrollcommand=scroll.set, height=5)
    scroll.config(command=select.yview)
    select.grid(row=4, column=5)

    FormationLabel = Label(GUIFrame, text="Formation Selected").grid(row=3,
                                                                     column=9)
    FormationVar = StringVar(GUIFrame)
    FormationVar.set('')
    FormationDisplay = Entry(GUIFrame,
                             textvariable=FormationVar).grid(row=4,
                                                             column=10,
                                                             sticky=W)

    AddButton = Button(GUIFrame, text="Add",
                       command=AddFormation).grid(row=4, column=6)
    GenerateButton = Button(GUIFrame, text="Generate",
                            command=createSquad).grid(row=4,
                                                      column=11,
                                                      padx=20)
    ClearButton = Button(GUIFrame, text="Clear",
                         command=clearButton).grid(row=4, column=12, padx=20)
    setList()
    return GUIFrame
コード例 #24
0
def buildFrame():
    Val_1 = "Opening Compare Two Teams Menu"
    DB.InsertLogs(Val_1)

    global select, root, Teamname1Var, Teamname2Var, Team1, Team2, AddTeam1Button, AddTeam2Button
    print("Start")
    #Build Frame
    root = Tk()
    root.title("Country Stats")
    root.resizable(width=FALSE, height=FALSE)
    root.geometry('1000x650')

    GUIFrame = Frame(root)
    GUIFrame.grid(row=20, column=20)

    #Team1
    Team1Label = Label(GUIFrame, text="Team_1 Selected").grid(row=12, column=3)
    Teamname1Var = StringVar(GUIFrame)
    Team1 = Entry(GUIFrame, textvariable=Teamname1Var).grid(row=12,
                                                            column=4,
                                                            sticky=E)

    #Team2
    Team1Label = Label(GUIFrame, text="Team_2 Selected").grid(row=13, column=3)
    Teamname2Var = StringVar(GUIFrame)
    Team2 = Entry(GUIFrame, textvariable=Teamname2Var).grid(row=13,
                                                            column=4,
                                                            sticky=E)

    DisplayCountryLabel = Label(
        GUIFrame, text="Below are the available Teams").grid(row=11, column=0)
    scroll = Scrollbar(GUIFrame, orient=VERTICAL)
    select = Listbox(GUIFrame, yscrollcommand=scroll.set, height=25)
    scroll.config(command=select.yview)
    select.grid(row=12, column=0)

    #Header
    Heading = Label(GUIFrame,
                    text="Welcome To FIFA 18 Player Stats Club Stats").grid(
                        row=1, column=3)
    AddTeam1Button = Button(GUIFrame, text="Add Team_1",
                            command=LoadTeam1).grid(row=12, column=2)
    AddTeam2Button = Button(GUIFrame, text="Add Team_2",
                            command=LoadTeam2).grid(row=13, column=2)

    RemoveTeam1Button = Button(GUIFrame,
                               text="Clear Team_1",
                               command=lambda: clearTeam(1)).grid(row=12,
                                                                  column=6,
                                                                  padx=30)
    RemoveTeam2Button = Button(GUIFrame,
                               text="Clear Team_2",
                               command=lambda: clearTeam(2)).grid(row=13,
                                                                  column=6,
                                                                  padx=10)

    GenerateButton = Button(GUIFrame,
                            text="Generate",
                            command=lambda: PopulateData(
                                Teamname1Var.get(), Teamname2Var.get())).grid(
                                    row=26, column=4, pady=30)

    Distinct_Club_Final = GenerateClubs()
    setList(Distinct_Club_Final)

    root.mainloop()
    return GUIFrame
コード例 #25
0
def PopulateData(Team1, Team2):
    try:
        Val_1 = "Populating Data for Teams"
        DB.InsertLogs(Val_1)

        print(Team1)
        print(Team2)
        Gen_Values = []
        Gen_Values_1 = []
        Team_1 = []
        Team_2 = []

        #Validate the Teams and Null values
        if Team1 == "":
            tkinter.messagebox.showinfo("Error", "Team_1 Cannot be Empty")
            DB.InsertExceptionStmtTable("Team_1 Cannot be Empty",
                                        "Comapare Two  Teams - clearTeam")
        elif Team2 == "":
            tkinter.messagebox.showinfo("Error", "Team_2 Cannot be Empty")
            DB.InsertExceptionStmtTable("Team_2 Cannot be Empty",
                                        "Comapare Two  Teams - clearTeam")

        elif Team1 == Team2:
            tkinter.messagebox.showinfo("Error", "Team_1 and Team_2 are Same")
            DB.InsertExceptionStmtTable("Team_1 and Team_2 are Same",
                                        "Comapare Two  Teams - clearTeam")
        else:

            Val_1 = "Populating Data for Team_1"
            DB.InsertLogs(Val_1)
            #Extract Player overall stats from the file for Team1
            Players_Data = ER.extractRecords()
            for i in range(0, len(Players_Data)):
                if Players_Data[i][8] == str(Team1):
                    Gen_Values.append(int(Players_Data[i][6]))

            Val_1 = "Populating Data for Team_2"
            DB.InsertLogs(Val_1)
            #Extract Player overall stats from the file for Team2
            for i in range(0, len(Players_Data)):
                if Players_Data[i][8] == str(Team2):
                    Gen_Values_1.append(int(Players_Data[i][6]))

            print(len(Gen_Values))
            print(len(Gen_Values_1))

            Val_1 = "Sorting Data for Teams"
            DB.InsertLogs(Val_1)
            ##Sort values of each Team
            Team_1 = sorted(Gen_Values)
            Team_2 = sorted(Gen_Values_1)
            print(Team_1)
            print(Team_2)

            ##pass each Team values as a list for box Plot
            Val_1 = "Generate box Plot"
            DB.InsertLogs(Val_1)

            data = [Team_1, Team_2]
            plt.boxplot(data)

            fig, ax = plt.subplots(facecolor='#d2f53c')
            ax.boxplot(data, widths=0.3, patch_artist=True)
            plt.xlabel("Teams")
            ax.set_xticklabels([Team1, Team2])

            ax.set_facecolor("white")
            ax.yaxis.grid(linestyle='--')
            ax.xaxis.grid()

            plt.ylabel("Range of Players")
            plt.title("Team Comparison")
            plt.ylim(40, 100)
            fig.show()
            Val_1 = "Box Plot completed"
            DB.InsertLogs(Val_1)

    except Exception as e:
        print("Error", e)
        DB.InsertExceptionStmtTable(e, "Comapre Two Teams - PopulateData")
コード例 #26
0
def PopulateData(Player1_Name, Player2_Name):
    #print(Player1_Name)
    #print(Player2_Name)

    try:
        Val_1 = "Load Players data and Validate"
        DB.InsertLogs(Val_1)

        Player2_Values = []
        Player1_Values = []

        Player1_Name = str(Player1_Name).replace(",", '')
        Player2_Name = str(Player2_Name).replace(",", '')
        if Player1_Name == "":
            tkinter.messagebox.showinfo("Error", "Player1 Name is Empty")
            DB.InsertExceptionStmtTable("Player1 Name is Empty",
                                        "Players_Compare - PopulateData")
        elif Player2_Name == "":
            tkinter.messagebox.showinfo("Error", "Player2 Name is Empty")
            DB.InsertExceptionStmtTable("Player2 Name is Empty",
                                        "Players_Compare - PopulateData")

        elif Player1_Name == Player2_Name:
            tkinter.messagebox.showinfo("Error", "Same Player Choosen")
            DB.InsertExceptionStmtTable("Same Player Choosen",
                                        "Players_Compare - PopulateData")
        else:

            print("STR", Player1_Name)
            #print(FetchDataSQL+Player1_Name)

            Val_1 = "Open DB and Fect the Player 1 Overall and Potential"
            DB.InsertLogs(Val_1)
            conn = DB.OpenConnection()
            c = conn.cursor()
            c.execute(FetchDataSQL + Player1_Name)
            for overall, potenetial in c.fetchall():
                #print(overall)
                #print(potenetial)
                Player1_Values.append(overall)
                Player1_Values.append(potenetial)

            Val_1 = "Open DB and Fect the Player 2 Overall and Potential"
            DB.InsertLogs(Val_1)
            c = conn.cursor()
            c.execute(FetchDataSQL + Player2_Name)
            for overall, potenetial in c.fetchall():
                Player2_Values.append(overall)
                Player2_Values.append(potenetial)

            print(Player1_Values)
            print(Player2_Values)

            Val_1 = "Plot Barplots for Player 1 and Player 2 and Format"
            DB.InsertLogs(Val_1)
            y = np.arange(2)
            plt.autoscale(tight=True)
            Player1_color = ['red', 'green']
            Player2_color = ['blue', 'green']

            a = plt.bar(y + 1,
                        Player1_Values,
                        width=0.7,
                        alpha=1,
                        color=Player1_color,
                        edgecolor='black')
            b = plt.bar(y + 5,
                        Player2_Values,
                        width=0.7,
                        alpha=1,
                        color=Player2_color,
                        edgecolor='black')

            plt.xlim(0, 7)

            ##i is location, v is value for Legend

            for i, v in enumerate(Player1_Values):
                plt.text(i + 1, v + 1, str(v), fontweight='bold')

            for i, v in enumerate(Player2_Values):
                plt.text(i + 5, v + 1, str(v), fontweight='bold')

            plt.legend([a, b],
                       [Player1_Name + ' Overall', Player2_Name + ' Overall'],
                       loc=10)
            plt.ylim(0, 100)

            #plt.grid(True)
            #plt.spines['left'].set_linewidth(1)
            plt.xlabel('Players')
            plt.ylabel('Potential')
            plt.title('Overall vs Potential')
            plt.show()
    except Exception as e:
        DB.InsertExceptionStmtTable(e, "Players_Compare - PopulateData")
コード例 #27
0
def buildFrame():
    try:

        Val_1 = "Opening Players_Compare Menu"
        DB.InsertLogs(Val_1)

        global select, root, Player1_Var, Player2_Var, Team1, Team2, AddTeam1Button, AddTeam2Button
        print("Start")
        #Build Frame
        root = Tk()
        root.title("Country Stats")
        root.resizable(width=FALSE, height=FALSE)
        root.geometry('1000x650')

        GUIFrame = Frame(root)
        GUIFrame.grid(row=20, column=20)

        #Player1
        #Player1Label = Label(GUIFrame, text = "Team_1 Selected").grid(row=12, column=3)
        Player1_Var = StringVar(GUIFrame)
        Team1 = Entry(GUIFrame, textvariable=Player1_Var).grid(row=12,
                                                               column=4,
                                                               sticky=E)

        #Player2
        #Player2Label = Label(GUIFrame, text = "Team_2 Selected").grid(row=13, column=3)
        Player2_Var = StringVar(GUIFrame)
        Team2 = Entry(GUIFrame, textvariable=Player2_Var).grid(row=13,
                                                               column=4,
                                                               sticky=E)

        DisplayPlayerLabel = Label(GUIFrame,
                                   text="Below are the available Teams").grid(
                                       row=11, column=0)
        scroll = Scrollbar(GUIFrame, orient=VERTICAL)
        select = Listbox(GUIFrame, yscrollcommand=scroll.set, height=25)
        scroll.config(command=select.yview)
        select.grid(row=12, column=0)

        #Header
        Heading = Label(
            GUIFrame,
            text="Welcome To FIFA 18 Player Stats Club Stats").grid(row=1,
                                                                    column=3)
        AddTeam1Button = Button(GUIFrame,
                                text="Add Player_1",
                                command=LoadPlayer1).grid(row=12, column=2)
        AddTeam2Button = Button(GUIFrame,
                                text="Add Player_2",
                                command=LoadPlayer2).grid(row=13, column=2)

        RemoveTeam1Button = Button(GUIFrame,
                                   text="Clear Player_1").grid(row=12,
                                                               column=6,
                                                               padx=30)
        RemoveTeam2Button = Button(GUIFrame,
                                   text="Clear Player_2").grid(row=13,
                                                               column=6,
                                                               padx=10)

        GenerateButton = Button(
            GUIFrame,
            text="Generate",
            command=lambda: PopulateData(Player1_Var.get(), Player2_Var.get()
                                         )).grid(row=26, column=4, pady=30)

        setList()
        root.mainloop()
        return GUIFrame
    except Exception as e:
        DB.InsertExceptionStmtTable(e, "Players_Compare - buildFrame")
コード例 #28
0
def PlayersBasedOnAge():

    try:

        ##Log Statement
        Val_1 = "Started Age Distribution"
        DB.InsertLogs(Val_1)
        Players_Data = File.extractRecords(
        )  #Extract Record from the .csv file

        ##Declare variables for grouping players age
        Under10 = 0
        Under20 = 0
        Under30 = 0
        Under40 = 0
        Under50 = 0
        Undefined = 0
        age = []

        #Run through for loop, 2nd index value in the .csv file is the age

        for i in range(0, len(Players_Data) - 1):
            #print(i)
            age.append(Players_Data[i][2])
        #print(age[0])

        #Group each age and increment the counter
        for i in age:
            if int(i) >= 0 and int(i) < 10:
                Under10 = Under10 + 1
            elif int(i) >= 10 and int(i) < 20:
                Under20 = Under20 + 1
            elif int(i) >= 20 and int(i) < 30:
                Under30 = Under30 + 1
            elif int(i) >= 30 and int(i) < 40:
                Under40 = Under40 + 1
            elif int(i) >= 40 and int(i) < 50:
                Under50 = Under50 + 1
            else:
                Undefined = Undefined + 1

        #Map it to the dictionary
        Age_Dictionary = {
            "Under10": Under10,
            "Under20": Under20,
            "Under30": Under30,
            "Under40": Under40,
            "Under50": Under50,
            "Undefined": Undefined
        }
        print(Age_Dictionary)

        ## Backgroud format
        colors = [
            'white',
        ]
        plt.rcParams['axes.facecolor'] = '#AA0000'
        X_Axis = ('0-10', '10-20', '20-30', '30-40', '40-50', 'Undefined')
        y_pos = np.arange(len(X_Axis))
        plt.ylim(0, 20000)
        Age_Distribution = [
            Under10, Under20, Under30, Under40, Under50, Under10
        ]

        ##v is y values, i is location for the legend
        for i, v in enumerate(Age_Distribution):
            plt.text(i - .25, v + 100, str(v), fontweight='bold')
        plt.bar(y_pos,
                Age_Distribution,
                align='center',
                bottom=10,
                alpha=1,
                color=colors,
                edgecolor='black')
        plt.xticks(y_pos, X_Axis)
        font = 0
        plt.xlabel('Age Distribution')
        plt.ylabel('Total Players')
        plt.title('Age Classification')
        plt.show()

        Val_1 = "Completed Age Distribution"
        DB.InsertLogs(Val_1)
    except Exception as e:
        print("Error", e)
        DB.InsertExceptionStmtTable(e, "Age Screen")
コード例 #29
0
def generateSquad(Def, Mid, Att):
    try:

        Val_1 = "Fetching Players based on the values"
        DB.InsertLogs(Val_1)

        Defender = list()
        Midfielders = list()
        Attackers = list()
        GoalKeeper = list()

        Val_1 = "Opening Connection for Squad Creation"
        DB.InsertLogs(Val_1)

        conn = DB.OpenConnection()
        c = conn.cursor()

        Val_1 = "Fetching Defenders"
        DB.InsertLogs(Val_1)
        ##Fetch Defenders
        if Def == 5:
            DefSql_CB = "SELECT NAME FROM AC_FIFA18_READ_DATA where PreferredPositions like '%CB%' order by Overall desc LIMIT 3; "
            DefSql_RB = "SELECT NAME FROM AC_FIFA18_READ_DATA where PreferredPositions like '%RB%' order by Overall desc LIMIT 1; "
            DefSql_LB = "SELECT NAME FROM AC_FIFA18_READ_DATA where PreferredPositions like '%LB%' order by Overall desc LIMIT 1; "
            rows = c.execute(DefSql_CB)

            for row in rows:
                Defender.append(row)

            rows = c.execute(DefSql_LB)
            for row in rows:
                Defender.append(row)

            rows = c.execute(DefSql_RB)
            for row in rows:
                Defender.append(row)

            print(Defender)

        elif Def == 4:
            DefSql_CB = "SELECT NAME FROM AC_FIFA18_READ_DATA where PreferredPositions like '%CB%' order by Overall desc LIMIT 2;"
            DefSql_RB = "SELECT NAME FROM AC_FIFA18_READ_DATA where PreferredPositions like '%RB%' order by Overall desc LIMIT 1; "
            DefSql_LB = "SELECT NAME FROM AC_FIFA18_READ_DATA where PreferredPositions like '%LB%' order by Overall desc LIMIT 1; "
            rows = c.execute(DefSql_CB)

            for row in rows:
                Defender.append(row)

            rows = c.execute(DefSql_LB)

            for row in rows:
                Defender.append(row)

            rows = c.execute(DefSql_RB)

            for row in rows:
                Defender.append(row)

        elif Def == 3:

            DefSql_CB = "SELECT NAME FROM AC_FIFA18_READ_DATA where PreferredPositions like '%CB%' order by Overall desc LIMIT " + str(
                Def) + ";"
            rows = c.execute(DefSql_CB)

            for row in rows:
                Defender.append(row)

        else:
            pass

        Val_1 = "Fetching Midfielders"
        DB.InsertLogs(Val_1)
        ##Fetch Midfielders
        MidSql = "SELECT NAME FROM AC_FIFA18_READ_DATA WHERE PreferredPositions like '%CM%' order by Overall desc LIMIT " + str(
            Mid) + ";"
        rows = c.execute(MidSql)

        for row in rows:
            Midfielders.append(row)

        Val_1 = "Fetching Attackers"
        DB.InsertLogs(Val_1)
        ##Fetch Attackers
        AttSql = "SELECT NAME FROM AC_FIFA18_READ_DATA where PreferredPositions like '%ST%' OR PreferredPositions like '%RW%'\
                  order by Overall desc LIMIT " + str(Att) + ";"
        rows = c.execute(AttSql)

        for row in rows:
            Attackers.append(row)

        Val_1 = "Fetching Goal Keeper"
        DB.InsertLogs(Val_1)
        ##Fetch Goal keepers
        GKSql = "SELECT NAME FROM AC_FIFA18_READ_DATA where PreferredPositions like '%GK%' order by Overall desc LIMIT 1;"
        rows = c.execute(GKSql)

        for row in rows:
            GoalKeeper.append(row)

        print("Defenders are ", Defender)
        print("Mid are ", Midfielders)
        print("Att are ", Attackers)
        print("GK are ", GoalKeeper)

        ## Listbox Formatting
        TeamLabel = Label(GUIFrame, text="Below is Your Team").grid(row=5,
                                                                    column=1,
                                                                    pady=10)
        scroll = Scrollbar(GUIFrame, orient=VERTICAL)
        BestTeam = Listbox(GUIFrame, yscrollcommand=scroll.set, height=30)
        scroll.config(command=select.yview)
        BestTeam.grid(row=6, column=1)

        ##Insert each players in the Listbox
        Val_1 = "Insert Players"
        DB.InsertLogs(Val_1)

        #Fetch Goal Keeper
        BestTeam.insert(END, "Goal Keeper: ")
        for i in GoalKeeper:
            BestTeam.insert(END, i)

        BestTeam.insert(END, "  ")
        BestTeam.insert(END, "  ")
        BestTeam.insert(END, "  ")
        BestTeam.insert(END, "Defenders: ")

        #Fetch Defenders
        for i in Defender:
            BestTeam.insert(END, i)

        BestTeam.insert(END, "  ")
        BestTeam.insert(END, "  ")
        BestTeam.insert(END, "  ")

        #Fetch Midfielders
        BestTeam.insert(END, "Midfielders: ")
        for i in Midfielders:
            BestTeam.insert(END, i)

        BestTeam.insert(END, "  ")
        BestTeam.insert(END, "  ")
        BestTeam.insert(END, "  ")

        #Fetch Attackers
        BestTeam.insert(END, "Attackers: ")
        for i in Attackers:
            BestTeam.insert(END, i)

    except Exception as a:
        print(a)
        DB.InsertExceptionStmtTable(a, "Best Team - generateSquad")
コード例 #30
0
def extractRecords():
    try:
        Val_1 = "Extract Records from the source Data"
        DB.InsertLogs(Val_1)
        data = []
        print("Executing Extract Records")
        with open(Source_Data, "r", encoding="utf8") as DataSet:
            printData = csv.reader(DataSet, delimiter=' ')
            for row in printData:
                data.append(row)

            Val_1 = "Split Records"
            DB.InsertLogs(Val_1)
            #Splitting ColNames into a seperate list
            for x in data[0]:
                x = x.split(",")
                ColNames.append(x)

            #Deleting the first row becuase we have written it in a seperate list
            del data[0]

            Players_Data = []
            print("DAta", len(data))
            print("Before appending", len(Players_Data))
            print("I'm Here Now in Extract Recorods")
            Val_1 = "Splitting Player Attributes into a seperate list based on the whitespaces"
            DB.InsertLogs(Val_1)
            #Splitting Player Attributes into a seperate list based on the whitespaces
            for i in range(0, len(data) - 1):
                if len(data[i]) == 8:
                    x = (data[i][0], data[i][1], data[i][2], data[i][3],
                         data[i][4], data[i][5], data[i][6], data[i][7])
                    y = (x[0] + " " + x[1] + " " + x[2] + " " + x[3] + " " +
                         x[4] + " " + x[5] + " " + x[6] + " " + x[7])
                    y = y.split(",")
                    Players_Data.append(y)

                elif len(data[i]) == 7:
                    x = (data[i][0], data[i][1], data[i][2], data[i][3],
                         data[i][4], data[i][5], data[i][6])
                    y = (x[0] + " " + x[1] + " " + x[2] + " " + x[3] + " " +
                         x[4] + " " + x[5] + " " + x[6])
                    y = y.split(",")
                    Players_Data.append(y)

                elif len(data[i]) == 6:
                    x = (data[i][0], data[i][1], data[i][2], data[i][3],
                         data[i][4], data[i][5])
                    y = (x[0] + " " + x[1] + " " + x[2] + " " + x[3] + " " +
                         x[4] + " " + x[5])
                    y = y.split(",")
                    Players_Data.append(y)

                elif len(data[i]) == 5:
                    x = (data[i][0], data[i][1], data[i][2], data[i][3],
                         data[i][4])
                    y = (x[0] + " " + x[1] + " " + x[2] + " " + x[3] + " " +
                         x[4])
                    y = y.split(",")
                    Players_Data.append(y)

                elif len(data[i]) == 4:
                    x = (data[i][0], data[i][1], data[i][2], data[i][3])
                    y = (x[0] + " " + x[1] + " " + x[2] + " " + x[3])
                    y = y.split(",")
                    Players_Data.append(y)
                elif len(data[i]) == 3:
                    x = (data[i][0], data[i][1], data[i][2])
                    y = (x[0] + " " + x[1] + " " + x[2])
                    y = y.split(",")
                    Players_Data.append(y)
                elif len(data[i]) == 2:
                    x = (data[i][0], data[i][1])
                    y = (x[0] + " " + x[1])
                    y = y.split(",")
                    Players_Data.append(y)
                elif len(data[i]) == 1:
                    x = (data[i][0])
                    y = (x[0])
                    y = y.split(",")
                    Players_Data.append(y)
                else:
                    #print("Not Empty")
                    print(data[i])

            print("Completed Extract of Records")
            print(len(data))
            print("Here in Extract Records", len(Players_Data))
            Val_1 = "Extract Completed"
            DB.InsertLogs(Val_1)
            return Players_Data
    except Exceptoion as e:
        DB.InsertExceptionStmtTable(e, "Extract Records - extractRecords")