-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_data.py
More file actions
34 lines (26 loc) · 1.13 KB
/
test_data.py
File metadata and controls
34 lines (26 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# test_data.py
import pandas as pd
import os
import traceback
print("--- Starting Data File Test ---")
# Define the path exactly as it is in your tools.py
DATA_DIR = "./data"
PATIENT_DB_PATH = os.path.join(DATA_DIR, "patients.csv")
try:
print(f"Attempting to read file from path: {os.path.abspath(PATIENT_DB_PATH)}")
# Use the same logic as the tool to read the file
patients_df = pd.read_csv(PATIENT_DB_PATH, encoding='utf-8')
print("\n✅ SUCCESS! The patients.csv file was read successfully.")
print(f"Number of patients found: {len(patients_df)}")
print("\nFirst 3 rows of data:")
print(patients_df.head(3))
except FileNotFoundError:
print("\n❌ ERROR: FileNotFoundError")
print(f"The file was not found at the expected path: {os.path.abspath(PATIENT_DB_PATH)}")
print("Please make sure your 'patients.csv' file is inside the 'data' directory.")
except Exception:
print(f"\n❌ ERROR: An unexpected error occurred while reading the file.")
print("This is the traceback that we need to fix the issue:")
# Print the full traceback
traceback.print_exc()
print("\n--- Test Complete ---")