Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rama-1 #36

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions App/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import model
import time
import csv

csv.field_size_limit(2147483647)

"""
El controlador se encarga de mediar entre la vista y el modelo.
Expand All @@ -36,21 +36,47 @@ def new_controller():
Crea una instancia del modelo
"""
#TODO: Llamar la función del modelo que crea las estructuras de datos
pass

control = {
"model" : None
}
control["model"] = model.new_data_structs()
return control

# Funciones para la carga de datos

def load_data(control, filename):
def load_data(control):

"""
Carga los datos del reto
"""
# TODO: Realizar la carga de datos
pass

filenameR = "football/results-utf8-small.csv"
filenameG = "football/goalscorers-utf8-small.csv"
filenameS = "football/shootouts-utf8-small.csv"
#TODO: Realizar la carga de datos
dtos = control["model"]
resultss = loaddata(dtos,filenameR, "results")
resultss1 = loaddata(dtos,filenameG , "goalscorers")
resultss2 = loaddata(dtos , filenameS , "shootouts" )
sort(resultss)
return resultss , resultss1 , resultss2

# Funciones de ordenamiento

def loaddata(dtos , filename, poci):
file = cf.data_dir + filename
input_file = csv.DictReader(open(file , encoding='utf-8'))
for date in input_file:
model.add_dataR(dtos,date,poci)
return dtos[poci]

def sizedtos(dtos):
r1 , r2, r3, = load_data(dtos)
return model.dtosSize(r1), model.dtosSize(r2) , model.dtosSize(r3)

def primeros(dtos):
r1 , r2, r3, = load_data(dtos)
return model.sublista(r1, 1 , 3) , model.sublista(r2, 1 , 3) , model.sublista(r3, 1 , 3)

def sort(control):
"""
Ordena los datos del modelo
Expand Down
26 changes: 21 additions & 5 deletions App/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,34 @@ def new_data_structs():
manera vacía para posteriormente almacenar la información.
"""
#TODO: Inicializar las estructuras de datos
pass

dtos = {
"results": None,
"goalscorers" : None,
"shootouts" : None
}
dtos["results"] = lt.newList('ARRAY_LIST')
dtos["goalscorers"] = lt.newList('ARRAY_LIST')
dtos["shootouts"] = lt.newList('ARRAY_LIST')

return dtos


# Funciones para agregar informacion al modelo

def add_data(data_structs, data):
def add_dataR(data_structs, data , posci):
"""
Función para agregar nuevos elementos a la lista
"""
#TODO: Crear la función para agregar elementos a una lista
pass
#TODO: Crear la función para agregar elementos
lt.addLast(data_structs[posci],data)
return data_structs
# Funciones para creacion de datos


# Funciones para creacion de datos
def sublista(data_structs, pos_i , num):
sublista = lt.subList(data_structs ,pos_i,num)
return sublista

def new_data(id, info):
"""
Expand Down Expand Up @@ -156,6 +170,8 @@ def req_8(data_structs):


# Funciones utilizadas para comparar elementos dentro de una lista
def dtosSize(data_structs):
return lt.size(data_structs)

def compare(data_1, data_2):
"""
Expand Down
62 changes: 52 additions & 10 deletions App/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
from DISClib.ADT import list as lt
from DISClib.ADT import stack as st
from DISClib.ADT import queue as qu
assert cf
from tabulate import tabulate

assert cf
import traceback

default_limit = 1000
sys.setrecursionlimit(default_limit*10)

"""
La vista se encarga de la interacción con el usuario
Presenta el menu de opciones y por cada seleccion
Expand All @@ -42,8 +46,9 @@ def new_controller():
"""
Se crea una instancia del controlador
"""
control = controller.new_controller()
#TODO: Llamar la función del controlador donde se crean las estructuras de datos
pass
return control


def print_menu():
Expand All @@ -65,8 +70,8 @@ def load_data(control):
Carga los datos
"""
#TODO: Realizar la carga de datos
pass

result = controller.load_data(control)
return result

def print_data(control, id):
"""
Expand All @@ -77,12 +82,47 @@ def print_data(control, id):

def print_req_1(control):
"""
Función que imprime la solución del Requerimiento 1 en consola
Función que imprime la soluci1ón del Requerimiento 1 en consola
Imprime los 3 primeros y los 3 ultimos cargados de los 3 archivos .

control: la estrcutura de datos a cargar.
"""

# TODO: Imprimir el resultado del requerimiento 1
pass


rt , gl , sh = controller.sizedtos(control)
l1, l2,l3 = controller.primeros(control)
print(('Match results count: ' + str(rt)).center(130))
print(('Goal scorers count: ' + str(gl)).center(130))
print(('Shootouts-penalty definition count: ' + str(sh)).center(130))
print("".center(130,"-"))
print("".center(130,"="))
print("FIFA RECORDS REPORT".center(130,"="))
print("".center(130,"="))

print("Print results for the first 3 and 3 last records on file.\n".center(130))

print("".center(130,"-"))
print("MATCH RESULTS".center(130,"-"))
print("".center(130,"-"))
print(" Total match results: " +str(rt))
print("Results struct has more than 6 records...")
print(tabulate(l1["elements"] , headers = "keys" , tablefmt='grid'))

print("".center(130,"-"))
print("GOAL SCORERS".center(130,"-"))
print("".center(130,"-"))
print(" Total goal scorers: " +str(gl))
print("Results struct has more than 6 records...")
print(tabulate(l2["elements"], headers = "keys" , tablefmt='grid'))

print("".center(130,"-"))
print("SHOOTOUTS".center(130,"-"))
print("".center(130,"-"))
print(" Total shootouts: " +str(sh))
print("Results struct has more than 6 records...")
print(tabulate(l3["elements"], headers = "keys" , tablefmt='grid'))


def print_req_2(control):
"""
Función que imprime la solución del Requerimiento 2 en consola
Expand Down Expand Up @@ -153,8 +193,10 @@ def print_req_8(control):
print_menu()
inputs = input('Seleccione una opción para continuar\n')
if int(inputs) == 1:
print("Cargando información de los archivos ....\n")
data = load_data(control)
print("".center(130,"-"))
print("Cargando información de los archivos ....".center(130))
print("".center(130,"-"))
print(print_req_1(control))
elif int(inputs) == 2:
print_req_1(control)

Expand Down
1 change: 1 addition & 0 deletions Data/football/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is to keep the folder!
Binary file added Docs/Lab 4.pdf
Binary file not shown.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ This repository is part of the data structure and algorithms (#EDA) teaching fra

The students edit this section to add their names, Uniandes emails, and specify which project functionality of the project they will implement.

1. Student No. 1 Name, Student No. 1 Uniandes Email, Student No. 1 owned functionality.
1. Student No. 2 Name, Student No. 2 Uniandes Email, Student No. 2 owned functionality.
1. Student No. 3 Name, Student No. 3 Uniandes Email, Student No. 3 owned functionality.

1. Juan Lago, j.lagoa@uniandes.edu.co,
2. Juan David Ortiz Prada, jd.ortizp1@uniandes.edu.co,
3. Mauricio Martínez, m.martinezu@uniandes.edu.co,
[Back to top](#challenge-template)

<!-- ABOUT THE PROJECT -->
Expand Down