Summary
I have a samba server on my rPI, and I want to access some CSV
files in real-time if that is possible. The content of the CSV
will be changed from time to time. How can I do that?
I’ve tried based on examples what I’ve found on the internet:
Code snippet:
import streamlit as st # web development
import numpy as np # np mean, np random
import pandas as pd # read csv, df manipulation
import time # to simulate a real time data, time loop
import plotly.express as px # interactive charts
import urllib
from smb.SMBHandler import SMBHandler
# read csv from a github repo
df = pd.read_csv("smp://my.ip.address/PiShare/my/path/scan.csv")
st.set_page_config(
page_title='page',
layout='wide'
)
# dashboard title
st.title("Scanning results....")
# top-level filters
# job_filter = st.selectbox("Select the Job", pd.unique(df['job']))
#
# # creating a single-element container.
placeholder = st.empty()
#
# # dataframe filter
#
# df = df[df['job'] == job_filter]
# near real-time / live feed simulation
for seconds in range(200):
while True:
i =1
#df['age_new'] = df['age'] * np.random.choice(range(1, 5))
#df['balance_new'] = df['balance'] * np.random.choice(range(1, 5))
# creating KPIs
#avg_age = np.mean(df['age_new'])
#count_married = int(df[(df["marital"] == 'married')]['marital'].count() + np.random.choice(range(1, 30)))
#balance = np.mean(df['balance_new'])
with placeholder.container():
# create three columns
#kpi1, kpi2, kpi3 = st.columns(3)
# fill in those three columns with respective metrics or KPIs
# kpi1.metric(label="Age ⏳", value=round(avg_age), delta=round(avg_age) - 10)
# kpi2.metric(label="Married Count 💍", value=int(count_married), delta=- 10 + count_married)
# kpi3.metric(label="A/C Balance $", value=f"$ {round(balance, 2)} ",
# delta=- round(balance / count_married) * 100)
# create two columns for charts
z_data = pd.read_csv("smp://my.ip.address/PiShare/my/path/scan.csv")
z = z_data.values
sh_0, sh_1 = z.shape
x, y = np.linspace(0, 1, sh_0), np.linspace(0, 1, sh_1)
fig_col1, fig_col3, fig_col2 = st.columns(3)
with fig_col1:
st.markdown("heatmap")
fig = px.density_heatmap(data_frame=df, y='y', x='x')
st.write(fig)
with fig_col2:
st.markdown("barplot")
fig2 = px.bar(z_data[::-5], x='y', y='z')
#fig2 = px.histogram(data_frame=df, x='z')
st.write(fig2)
st.markdown("### Detailed Data View")
st.dataframe(df)
time.sleep(1)
# placeholder.empty()
But I’ve got FileNotFoundError: [Errno 2] No such file or directory