|
a |
|
b/stream_csv_data.py |
|
|
1 |
import requests |
|
|
2 |
import pandas as pd |
|
|
3 |
import time |
|
|
4 |
|
|
|
5 |
# Load CSV file |
|
|
6 |
file_path = "PPG_Dataset.csv" # Update with the correct path |
|
|
7 |
df = pd.read_csv(file_path) |
|
|
8 |
|
|
|
9 |
# Assuming the CSV has 'heart_rate' and 'spo2' columns |
|
|
10 |
for index, row in df.iterrows(): |
|
|
11 |
data = {"heart_rate": row["Heart_Rate"], "spo2": row["SpO2"]} |
|
|
12 |
|
|
|
13 |
# Send request to FastAPI server |
|
|
14 |
response = requests.post("http://127.0.0.1:8000/predict", json=data) |
|
|
15 |
|
|
|
16 |
# Print the response from the server |
|
|
17 |
print(f"Input: {data}, Output: {response.json()}") |
|
|
18 |
|
|
|
19 |
# Simulate real-time streaming by adding a delay |
|
|
20 |
time.sleep(1) # Adjust delay as needed |