mirror of
https://github.com/aykhans/HuaweiHealthDataVisualization.git
synced 2025-04-13 21:33:12 +00:00
Added 'data_access' module
This commit is contained in:
parent
29c80cf82c
commit
74079ef92d
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.venv
|
.venv
|
||||||
|
__pycache__
|
@ -1,5 +1,5 @@
|
|||||||
## Project Link
|
## Project Link
|
||||||
https://share.streamlit.io/ayxan-z/huaweihealthdatavisualization/main/app/main.py
|
https://ayxan-z-huaweihealthdatavisualization-appmain-vgn77h.streamlit.app/
|
||||||
|
|
||||||
## Instalition
|
## Instalition
|
||||||
**pip install -r requirements.txt <br />**
|
**pip install -r requirements.txt <br />**
|
||||||
|
@ -1,21 +1,24 @@
|
|||||||
# sourcery skip: list-comprehension
|
# sourcery skip: list-comprehension
|
||||||
|
from pathlib import Path
|
||||||
|
main_path: Path = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
from sys import path
|
||||||
|
path.append(main_path)
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import plotly.express as px
|
import plotly.express as px
|
||||||
import json
|
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from datetime import (datetime,
|
from datetime import (datetime,
|
||||||
timedelta)
|
timedelta)
|
||||||
from pathlib import Path
|
from data_access import LocalTestData
|
||||||
|
|
||||||
|
|
||||||
data_dir = Path(__file__).resolve().parent.parent / 'data'
|
|
||||||
|
|
||||||
st.set_page_config(page_title = 'Health Data Visualization',
|
st.set_page_config(page_title = 'Health Data Visualization',
|
||||||
page_icon = ':bar_chart:',
|
page_icon = ':bar_chart:',
|
||||||
layout = 'wide')
|
layout = 'wide')
|
||||||
|
|
||||||
with open(data_dir / 'huawei_health_data.json') as f:
|
local_data = LocalTestData('data')
|
||||||
data = json.load(f)
|
data = local_data.get_data('huawei_health_data.json')
|
||||||
|
|
||||||
heart_rate = []
|
heart_rate = []
|
||||||
for d in data:
|
for d in data:
|
1
src/data_access/__init__.py
Normal file
1
src/data_access/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
from .local_data_access import LocalTestData
|
13
src/data_access/local_data_access.py
Normal file
13
src/data_access/local_data_access.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
import json
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
|
class LocalTestData:
|
||||||
|
def __init__(self, data_folder_name: str) -> None:
|
||||||
|
self.data_dir: Path = Path(__file__).resolve().parent.parent.parent / data_folder_name
|
||||||
|
|
||||||
|
def get_data(self, file_name: str) -> List:
|
||||||
|
with open(self.data_dir / file_name) as f:
|
||||||
|
data: List = json.load(f)
|
||||||
|
return data
|
Loading…
x
Reference in New Issue
Block a user