CarlosOliveira1988 / Investment_Portfolio_Analysis

This repository is useful to perform some financial analysis in Investment Portfolio
4 stars 0 forks source link

Application accepts any kind of excel file when handling the portfolio spreadsheet #55

Closed CarlosOliveira1988 closed 2 years ago

CarlosOliveira1988 commented 2 years ago

Describe the bug

There is no filter to validate the excel file used as portfolio data. Then, several errors may appear when opening files with incorrect format.

To Reproduce

Steps to reproduce the behavior:

  1. Open the application from "main.py"
  2. Click on 'Arquivo -> Abrir'
  3. Open the target file
  4. See error:
    Traceback (most recent call last):
    File "d:\Dudu\Finanþas\Investimentos\Mercado Financeiro\Investment_Portfolio_Analysis\main.py", line 103, in _openFile        
    self.PortfolioViewerWidget.updateData(file_name)
    File "d:\Dudu\Finanþas\Investimentos\Mercado Financeiro\Investment_Portfolio_Analysis\portfolio_lib\portfolio_widget.py", line 243, in updateData
    self.porfolio_investment = PorfolioInvestment(file_name)
    File "d:\Dudu\Finanþas\Investimentos\Mercado Financeiro\Investment_Portfolio_Analysis\portfolio_lib\portfolio_investment.py", 
    line 27, in __init__
    self.numberOperationsYear()
    File "d:\Dudu\Finanþas\Investimentos\Mercado Financeiro\Investment_Portfolio_Analysis\portfolio_lib\portfolio_investment.py", 
    line 57, in numberOperationsYear
    firstYear = dataframe[
    File "C:\Users\Carlos\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\frame.py", line 3024, in __getitem__
    indexer = self.columns.get_loc(key)
    File "C:\Users\Carlos\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\core\indexes\base.py", line 3082, in get_loc
    raise KeyError(key) from err
    KeyError: 'Data'

Expected behavior

A message box shall be displayed in order to warn the user about the incorrect spreadsheet format

Screenshots

N/A

Desktop (please complete the following information):

N/A

Additional context

N/A

CarlosOliveira1988 commented 2 years ago

This ticket is resolved by the commit 15c1256. Please, check the results.