Trying to add record they are just not showing

i am making a school project on examination management so it a basically a program that manages csv file records and all but my code just isnt it working i just cannot understand why here is the code

import pandas as pd
import matplotlib.pyplot as plt
import os

FILE_PATH = "the path to the file/exam.csv"

def load_data():
    if os.path.exists(FILE_PATH):
        data = pd.read_csv(FILE_PATH)
        print("Data loaded successfully.")
        print(data.head())  
# Debug: print first few rows of the DataFrame
    else:
        print("File not found. Creating a new DataFrame.")
        columns = ["rollno", "name", "father_name", "adharrid", "age", "attempt", "lastattemptscore", "dateofbirth", "address", "phonenumber", "email"]
        data = pd.DataFrame(columns=columns)
    return data

def save_data(data):
    data.to_csv(FILE_PATH, index=False)
    print("Data saved successfully.")

def display_main_menu():
    print('*' * 80)
    print('                                  WELCOME TO EXAMINATION MANAGEMENT MENU    ')
    print('*' * 80)
    print('1. Show Examination Detailsn')
    print('2. Show Data Columns n')
    print('3. Display Top Recordsn')
    print('4. Display Bottom Recordsn')
    print('5. Display Specific Columnn')
    print('6. Add a New Recordn')
    print('7. Add a New Columnn')
    print('8. Delete a Columnn')
    print('9. Delete a Recordn')
    print('10. Update a Recordn')
    print('11. Move to Graph Menun')
    print('12. Exitn')

def handle_main_choice(data, choice):
    if choice == 1:
        print(data)
    elif choice == 2:
        print(data.columns)
    elif choice == 3:
        n = int(input('Enter number of top records to display: '))
        print(data.head(n))
    elif choice == 4:
        n = int(input('Enter number of bottom records to display: '))
        print(data.tail(n))
    elif choice == 5:
        col_name = input('Enter column name to display: ')
        if col_name in data.columns:
            print(data[col_name])
        else:
            print(f'Column "{col_name}" does not exist.')
    elif choice == 6:
        new_record = {
            "rollno": input('Enter Roll Number: '),
            "name": input('Enter Name: '),
            "father_name": input('Enter Father Name: '),
            "adharrid": input('Enter Aadhar ID: '),
            "age": int(input('Enter Age: ')),
            "attempt": int(input('Enter Attempt Number: ')),
            "lastattemptscore": float(input('Enter Last Attempt Score: ')),
            "dateofbirth": input('Enter Date of Birth (YYYY-MM-DD): '),
            "address": input('Enter Address: '),
            "phonenumber": input('Enter Phone Number: '),
            "email": input('Enter Email: ')
        }
        new_df = pd.DataFrame([new_record])
        data = pd.concat([data, new_df], ignore_index=True)
        save_data(data)
        load_data()
    elif choice == 7:
        col_name = input('Enter new column name: ')
        default_value = input('Enter default value for the new column: ')
        if col_name not in data.columns:
            data[col_name] = default_value
            save_data(data)
        else:
            print(f'Column "{col_name}" already exists.')
    elif choice == 8:
        col_name = input('Enter column name to delete: ')
        if col_name in data.columns:
            data = data.drop(columns=[col_name])
            save_data(data)
        else:
            print(f'Column "{col_name}" does not exist.')
    elif choice == 9:
        index_no = int(input('Enter the index number of the record to delete: '))
        if index_no in data.index:
            data = data.drop(index_no)
            save_data(data)
        else:
            print(f'Index {index_no} does not exist.')
    elif choice == 10:
        index_no = int(input('Enter the index number of the record to update: '))
        if index_no in data.index:
            updated_record = {
                "rollno": input('Enter Roll Number: '),
                "name": input('Enter Name: '),
                "father_name": input('Enter Father Name: '),
                "adharrid": input('Enter Aadhar ID: '),
                "age": int(input('Enter Age: ')),
                "attempt": int(input('Enter Attempt Number: ')),
                "lastattemptscore": float(input('Enter Last Attempt Score: ')),
                "dateofbirth": input('Enter Date of Birth (YYYY-MM-DD): '),
                "address": input('Enter Address: '),
                "phonenumber": input('Enter Phone Number: '),
                "email": input('Enter Email: ')
            }
            data.loc[index_no] = updated_record
            save_data(data)
        else:
            print(f'Index {index_no} does not exist.')
    elif choice == 11:
        graph_menu(data)
    elif choice == 12:
        print("Exiting the system. Thank you!")
        return False
    return True

def display_graph_menu():
    print('*' * 80)
    print('                          GRAPH MENU                             ')
    print('*' * 80)
    print('1. Age Distribution Histogramn')
    print('2. Attempt Distribution Bar Graphn')
    print('3. Last Attempt Score Scatter Plotn')
    print('4. Exit to Main Menun')

def handle_graph_choice(data, choice):
    if choice == 1:
        plt.hist(data['age'].dropna(), bins=10, edgecolor='black')
        plt.xlabel('Age')
        plt.ylabel('Frequency')
        plt.title('Age Distribution')
        plt.show()
    elif choice == 2:
        attempt_counts = data['attempt'].value_counts().sort_index()
        attempt_counts.plot(kind='bar')
        plt.xlabel('Attempt Number')
        plt.ylabel('Number of Records')
        plt.title('Attempt Distribution')
        plt.show()
    elif choice == 3:
        plt.scatter(data['attempt'], data['lastattemptscore'])
        plt.xlabel('Attempt Number')
        plt.ylabel('Last Attempt Score')
        plt.title('Last Attempt Score vs Attempt Number')
        plt.show()
    elif choice == 4:
        return False
    return True

def main():
    data = load_data()
    while True:
        display_main_menu()
        try:
            choice = int(input('Enter your choice: '))
            if not handle_main_choice(data, choice):
                break
        except ValueError:
            print("Invalid input. Please enter a number.")
    
    while True:
        display_graph_menu()
        try:
            choice = int(input('Enter your choice: '))
            if not handle_graph_choice(data, choice):
                break
        except ValueError:
            print("Invalid input. Please enter a number.")

if __name__ == "__main__":
    main()

so i tried adding records to the code and they were getting added to the csv but still the terminal when i run the code it was saying empty dataframe.

New contributor

QBBT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật