�
b�hS � �D � d dl Z d dlZd dlmZmZmZ deeeef fd�Zy)� N)�List�Dict�Any�returnc � � d} t j j | � sg S g } t | dd�� 5 }t j
|� }|D ]I }|j
dd� |j
dd� |j
dd� d �}|j |� �K d
d
d
� |S # 1 sw Y |S xY w# t $ r}t d|� �� g cY d
}~S d
}~ww xY w)a�
Fetches all previously stored user data from the 'registration.csv' file
and returns it as a list of dictionaries, suitable for table display.
Returns:
List[Dict[str, Any]]: A list of dictionaries, where each dictionary
represents a registered user with 'Name', 'email', and 'dob' keys.
Returns an empty list if no users are registered or an error occurs.
zregistration.csv�r� )�newline�NamezN/A�email�dob)r �Email�DOBNz!Error fetching data in fetch.py: )
�os�path�exists�open�csv�
DictReader�get�append� Exception�print)� file_path�users�csvfile�reader�row� user_data�es �2/home/pallavi/Documents/mcp_project/tools/fetch.py�
fetch_datar"