-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretrieve.py
31 lines (23 loc) · 874 Bytes
/
retrieve.py
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
import pandas as pd
import os
import json
from main import plot
def retrieve_run_data(run_number, directory):
file_name = f'engine_run_{run_number}.json'
file_path = os.path.join(directory, file_name)
if not os.path.exists(file_path):
raise FileNotFoundError(f"No data found for engine run number {run_number}")
with open(file_path, 'r') as f:
engine_run_data = json.load(f)
engine_df = pd.DataFrame(engine_run_data["Data"])
return engine_df
if __name__ == '__main__':
current_directory = os.path.dirname(os.path.abspath(__file__))
directory = os.path.join(current_directory, 'engine_runs')
print(directory)
run_num = 1
df = retrieve_run_data(run_num, directory)
pd.set_option('display.max_columns', None)
print(f'Here is the data frame for Engine Run {run_num}:')
print(df)
plot(df, 'RPM')