HELP! newbie here,,

Hi Folks,
I’m brand new at this and was wondering if someone could possibly help or point me to right direction.
I’m using pandas, streamlit bar chart to display some data that is being FTP to a PC every 30 minutes.
The first issue i was getting is that, because the file is open, it stop coming through.
Then I decide to rename the file in a script, but then because it comes through every 30 minutes it keep saying that file exist so it can’t be changed.
Example:
old_file = “C:\users\reportingRpt\Staging_today.csv”
new_file = “C:\users\reportingRpt\todayRpt.csv”
os.rename(old_fine,new_file)

st.bart_chart(new_file)

Again, sorry I’m very new with this, and just learning…

Thanks

Try with this:

import streamlit as st
import pandas as pd
from datetime import timedelta

@st.fragment(run_every=timedelta(seconds=10))
def load_csv_file_and_display(file_path):
    print(f"Loading CSV file: {file_path}")
    df = pd.read_csv(file_path)
    # st.dataframe(df)
    st.bar_chart(df, x="x", y="y")

st.title("Display bar chart")
file_path = "./path/to/file.csv"

load_csv_file_and_display(file_path)
2 Likes

:raised_hands: Can’t thank you enough that worked. I really appreciate it.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.