This project provides a RESTful API allowing users to upload Excel files and extract specific information from them using natural language queries. The backend is built using Django and Django REST Framework, and it uses Tapas to interpret natural language and retrieve relevant data from the Excel files.
- Upload Excel files for analysis.
- Extract information from Excel files using natural language.
- Support for querying multiple types of data, including numbers, dates, and text.
To install and run this project locally, follow these steps:
git clone https://github.com/ayoub377/api_excel.gitcd api_excelpython -m venv env
source env/bin/activate # On Windows use `env\Scripts\activate`pip install -r requirements.txtpython manage.py migratepython manage.py runserverThe API will be accessible at http://localhost:8000.
- Upload an Excel File
POST /api/excel/upload
Request: The file should be sent as a form-data file. Response:
{
"id": "file_id",
"message": "File uploaded successfully."
}
- Query Excel File with Natural Language
Resquest:
POST /api/excel/{file_id}/?tapas_queries=What is the total sales in 2023?Response:{ "tapas_queries": "What is the total sales in 2023?" }{ "answer": "The total sales in 2023 is $500,000." } - Get Uploaded Excel Files
GET /api/excel/files
Description: Retrieve a list of all uploaded Excel files.
Response:
```
[
{
"id": "file_id",
"filename": "sales_data.xlsx",
"upload_date": "2024-09-12"
}
]
```
- Django: Python web framework.
- Django REST Framework: Toolkit for building Web APIs.
- Tapas: Table-based question-answering model for handling natural language queries.
- Pandas: For Excel data manipulation.
- OpenPyXL: For reading/writing Excel files.
- Upload: Users upload Excel files via the /upload endpoint.
- Natural Language Queries: Users ask questions in natural language, like "What is the total revenue in 2023?" The API processes this query and retrieves relevant data from the uploaded Excel file.
- Response: The system uses Tapas to interpret the query and return the answer in JSON format.