Mouaador commited on
Commit
d545106
·
verified ·
1 Parent(s): b0d134b

Create data_loader.py

Browse files
Files changed (1) hide show
  1. data_loader.py +20 -0
data_loader.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import gradio as gr
3
+
4
+ def load_data_from_file(file_obj):
5
+ try:
6
+ df = pd.read_csv(file_obj.name, sep=";")
7
+ if df.empty:
8
+ gr.Warning("Le fichier CSV est vide.")
9
+ return None, 0
10
+
11
+ required_cols = [f"{lm}_{axis}_mean" for lm in ["SHOULDER", "ELBOW", "WRIST", "INDEX", "THUMB"] for axis in ['X', 'Y', 'Z']]
12
+ if not all(col in df.columns for col in required_cols):
13
+ gr.Warning("Colonnes manquantes dans le fichier CSV.")
14
+ return None, 0
15
+
16
+ return df, len(df)
17
+
18
+ except Exception as e:
19
+ gr.Error(f"Erreur de lecture CSV: {str(e)}")
20
+ return None, 0