Spaces:
Runtime error
Runtime error
castorfou
commited on
Commit
·
efc3a78
1
Parent(s):
08a1a7c
2022-10-07_13:36
Browse files- __init__.py +1 -0
- app.py +33 -0
- rbc.py +30 -0
__init__.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
__version__ = "0.0.1"
|
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../main.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['analyse_fichier']
|
5 |
+
|
6 |
+
# %% ../main.ipynb 2
|
7 |
+
import gradio as gr
|
8 |
+
import pandas as pd
|
9 |
+
import tempfile
|
10 |
+
from pathlib import Path
|
11 |
+
from .rbc import add_classements
|
12 |
+
|
13 |
+
|
14 |
+
def analyse_fichier(file):
|
15 |
+
fichier = file[0]
|
16 |
+
fichier_save = Path(fichier.name).stem
|
17 |
+
print(fichier_save)
|
18 |
+
|
19 |
+
df_adherents = pd.read_excel(fichier)
|
20 |
+
df_classements = add_classements(df_adherents)
|
21 |
+
|
22 |
+
with tempfile.NamedTemporaryFile(prefix=fichier_save+'_', suffix=".xlsx", delete=False) as temp:
|
23 |
+
print(temp.name)
|
24 |
+
df_classements.to_excel(temp.name)
|
25 |
+
return temp.name
|
26 |
+
|
27 |
+
with gr.Blocks() as classement_converter:
|
28 |
+
file = gr.File(label="Adhérents", file_count=1)
|
29 |
+
greet_btn = gr.Button("Ajoute Classements")
|
30 |
+
outputs = gr.File(label="Adhérents avec classement", file_count=1, visible=True)
|
31 |
+
greet_btn.click(fn=analyse_fichier, inputs=file, outputs=outputs)
|
32 |
+
|
33 |
+
classement_converter.launch()
|
rbc.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../update_classement.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['PAGE', 'html_tables', 'df_adherents', 'get_classement', 'add_classements']
|
5 |
+
|
6 |
+
# %% ../update_classement.ipynb 2
|
7 |
+
PAGE = 'https://badmania.fr/club-joueurs-2254-riom-badminton-club.html'
|
8 |
+
|
9 |
+
# %% ../update_classement.ipynb 3
|
10 |
+
import pandas as pd
|
11 |
+
html_tables = pd.read_html(PAGE)
|
12 |
+
df_adherents = html_tables[0]
|
13 |
+
|
14 |
+
|
15 |
+
# %% ../update_classement.ipynb 7
|
16 |
+
def get_classement(
|
17 |
+
license_number,# le numero de license
|
18 |
+
):
|
19 |
+
# print(license_number)
|
20 |
+
if len(df_adherents[df_adherents['Licence'] == license_number]['Class.'].values)>0:
|
21 |
+
return df_adherents[df_adherents['Licence'] == license_number]['Class.'].values[0]
|
22 |
+
else:
|
23 |
+
return ''
|
24 |
+
|
25 |
+
# %% ../update_classement.ipynb 19
|
26 |
+
def add_classements(dataframe, #le dataframe des adherents
|
27 |
+
):
|
28 |
+
dataframe = dataframe.copy()
|
29 |
+
dataframe['Classement']= dataframe['Licence'].apply(lambda x: get_classement(x))
|
30 |
+
return dataframe
|