Spaces:
Running
Running
add
Browse files
app.py
CHANGED
|
@@ -74,7 +74,7 @@ from PIL import Image
|
|
| 74 |
import io
|
| 75 |
import docx2txt
|
| 76 |
from fastapi.responses import StreamingResponse
|
| 77 |
-
|
| 78 |
|
| 79 |
# Configuration du logging
|
| 80 |
logging.basicConfig(level=logging.INFO)
|
|
@@ -197,7 +197,8 @@ async def generate_viz(file: UploadFile = File(...), query: str = Form(...)):
|
|
| 197 |
if query not in VALID_PLOTS:
|
| 198 |
return JSONResponse(content={"error": f"Type de graphique invalide. Choisissez parmi : {', '.join(VALID_PLOTS)}"}, status_code=400)
|
| 199 |
|
| 200 |
-
|
|
|
|
| 201 |
numeric_cols = df.select_dtypes(include=["number"]).columns
|
| 202 |
|
| 203 |
if len(numeric_cols) < 1:
|
|
|
|
| 74 |
import io
|
| 75 |
import docx2txt
|
| 76 |
from fastapi.responses import StreamingResponse
|
| 77 |
+
from io import BytesIO
|
| 78 |
|
| 79 |
# Configuration du logging
|
| 80 |
logging.basicConfig(level=logging.INFO)
|
|
|
|
| 197 |
if query not in VALID_PLOTS:
|
| 198 |
return JSONResponse(content={"error": f"Type de graphique invalide. Choisissez parmi : {', '.join(VALID_PLOTS)}"}, status_code=400)
|
| 199 |
|
| 200 |
+
file_content = await file.read() # <- on lit tout
|
| 201 |
+
df = pd.read_excel(BytesIO(file_content)) # <- on lit depuis un buffer
|
| 202 |
numeric_cols = df.select_dtypes(include=["number"]).columns
|
| 203 |
|
| 204 |
if len(numeric_cols) < 1:
|