import glob


def list_data_files(data_path ="./data/*.csv"):
    """List available file to do the data analysis and group in a dict according the data frequency.

    Files should have the following structure:
        WIN$N_10M_2013.11.08_2021.01.22_.csv
        {ativo}_{frequencia}_{data_inicio}_{data_fim}_.csv

    Parameters
    ----------
    data_path: str
        path to look for the files.

    Returns
    -------
    dict_files: dict
        dict with frequencies as keys and list of files as values.

    Examples
    --------
    >>> list_data_files()
    {'10M': ['./data\\WIN$N_10M_2013.11.08_2021.01.22_.csv'],
    '15M': ['./data\\WIN$N_15M_2012.04.20_2021.01.22_.csv']}

    """
    dict_files = {}
    files = glob.glob(data_path)
    for file in files:
        freq = file.split(".")[1].split("_")[1]
        if freq in list(dict_files.keys()):
            dict_files[freq].append(file)
        else:
            dict_files[freq] = [file]
    return dict_files