Skip to content

Instantly share code, notes, and snippets.

@poltys
poltys / streamlit-db-connector.py
Created September 1, 2020 19:43
Streamlit DB connector using pymysql
import pandas as pd
import streamlit as st
import pymysql
from sqlalchemy import create_engine
st.sidebar.header('User Input Parameters')
date = pd.datetime.today()
server = st.sidebar.text_input('Server Name', '')
@poltys
poltys / upload-modelh5.py
Last active September 2, 2020 13:39
streamlit-dashboard-upload-h5-model
import zipfile
import tempfile
stream = st.file_uploader('TF.Keras model file (.h5py.zip)', type='zip')
if stream is not None:
myzipfile = zipfile.ZipFile(stream)
with tempfile.TemporaryDirectory() as tmp_dir:
myzipfile.extractall(tmp_dir)
root_folder = myzipfile.namelist()[0] # e.g. "model.h5py"
model_dir = os.path.join(tmp_dir, root_folder)
@poltys
poltys / json-mapping.py
Last active September 15, 2020 09:20
In a given folder read all json files and map the columns in a dataframe
# in a given folder read all json files and map the columns in a dataframe
import pandas as pd
import os, json
import glob
import numpy as np
def read_path(path):
folder_name = path
all_files = glob.glob(path + "/*.json")
@poltys
poltys / xml-mapping.py
Created September 15, 2020 09:22
In (a) given folder(s) read all xml files and map the columns in a dataframe
import pandas as pd
import os
import glob
import io
import xml.etree.ElementTree as ET
def read_path(path):
folder_name=path
all_files = glob.glob(path + "/*.xml")
files=[]