generated from streamlit/streamlit-hello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
streamOps.py
55 lines (34 loc) · 975 Bytes
/
streamOps.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import json
from pathlib import Path
import streamlit as st
@st.cache_data
def rd_json_file(fDir, fName):
file_dir = fDir
file_name = fName
file_path = f"{str(Path.cwd())}/{file_dir}/{file_name}.json"
with open(file_path, "r") as fileObj:
rawData = json.load(fileObj)[0]
return rawData
@st.cache_data
def clean_col_lst(rawData, fStr):
raw_data = []
for item in rawData:
if item.find(fStr) >= 0:
continue
else:
raw_data.append(item)
return raw_data
@st.cache_data
def json_to_array(fDir, fName, colData):
file_dir = fDir
file_name = fName
file_path = f"{str(Path.cwd())}/{file_dir}/{file_name}.json"
with open(file_path, "r") as fileObj:
rawData = json.load(fileObj)
raw_data = []
for row in rawData:
row_data = []
for col in colData:
row_data.append(row[col])
raw_data.append(row_data)
return raw_data