A FastAPI application that processes capital budgeting Excel files and provides REST API endpoints to extract financial data from multiple tables.
pip install -r requirements.txt- Create
Datafolder in project root - Place your
capbudg.xlsfile in theDatafolder - Run the application:
python run.pyReturns API information and available endpoints.
Lists all detected table names from the Excel file.
Response:
{
"tables": ["Initial Investment", "DISCOUNT RATE", "WORKING CAPITAL"]
}Returns row names for a specific table.
Parameters:
table_name: Name of the table (from list_tables response)
Response:
{
"table_name": "Initial Investment",
"row_names": ["Initial Investment=", "Tax Credit (if any )=", "Salvage Value at end of project="]
}Calculates sum of numerical values in a specific row.
Parameters:
table_name: Name of the tablerow_name: Name of the row (from get_table_details response)
Response:
{
"table_name": "Initial Investment",
"row_name": "Tax Credit (if any )=",
"sum": 10
}Shows raw Excel data structure for debugging.
- List tables:
http://localhost:9090/list_tables - Get table details:
http://localhost:9090/get_table_details?table_name=Initial%20Investment - Calculate row sum:
http://localhost:9090/row_sum?table_name=Initial%20Investment&row_name=Tax%20Credit%20(if%20any%20)%3D
- Swagger UI:
http://localhost:9090/docs - ReDoc:
http://localhost:9090/redoc
project/
├── main.py # FastAPI application
├── run.py # Application runner
├── requirements.txt # Dependencies
├── README.md # This file
└── Data/
└── capbudg.xls # Excel file to process
- FastAPI
- pandas
- openpyxl
- xlrd
- uvicorn
The application could be enhanced by supporting multiple Excel file formats (.xlsx, .csv) and implementing dynamic file upload functionality instead of requiring files in a specific directory.
The current implementation may not handle completely empty Excel files or files with only header rows without any numerical data, which could cause processing errors. The application assumes a specific Excel structure and may fail with files that have merged cells, multiple sheets, or unconventional layouts.