How to read a folder full of excel files

Hey @Cyubahiro_Patrick,

Thanks for linking your google drive with some test excel files, they were very helpful for me to test the code you sent.

So I have this working locally:
Firstly, in your def main() you need to add in a couple logic statements so that if the user has not put in anything in your input fields, the app does not try to run with those empty. Those are both errors that you have screenshotted in your drive:

I have fixed this like so:

def main():

    folderPath = st.text_input('Enter Abys bus monthly data folder path:')
    #I want to pass a folder path with many excel files that are read
    if len(folderPath) != 0:
        files = file_selector(folderPath)
        df0 = files[['Unnamed: 5', 'Unnamed: 6', 'Unnamed: 7', 'Unnamed: 28', 'Unnamed: 29']]
        df0.rename({'Unnamed: 5':'PlateNumber','Unnamed: 6':'Line Code','Unnamed: 7':'Start Date ','Unnamed: 28':'Total Pieces ','Unnamed: 29':'Total RWF'}, axis=1, inplace=True)
        #df['month_year'] = pd.to_datetime(df['Start Date ']).dt.to_period('M')
        st.write(df0)


    occPath = st.text_input('Enter the occupany data :')
    if len(occPath) != 0:
        files = file_selector(occPath)
        df1 = files[['Unnamed: 5', 'Unnamed: 6', 'Unnamed: 7', 'Unnamed: 28', 'Unnamed: 29']]
        df1.rename({'Unnamed: 5':'PlateNumber','Unnamed: 6':'Line Code','Unnamed: 7':'Start Date ','Unnamed: 28':'Total Pieces ','Unnamed: 29':'Total RWF'}, axis=1, inplace=True)
        #df['month_year'] = pd.to_datetime(df['Start Date ']).dt.to_period('M')
        st.write(df1)

I was also more specific about the 2 paths your taking in and your data frames, giving them unique names. Because Streamlit runs your script from top to bottom each time you interact with a widget on the page, if you are overwriting your dataframes and paths you could run into trouble.

Once this was working fine, I actually ran into another problem, because I didnโ€™t have xlrd installed. So i was able to install that following info from this link:
pip install xlrd OR conda install -c anaconda xlrd

And then it runs and the data loads. Now I am not able to enter any info into the second text_input because I am not sure what data your looking for here. But here is the app working up to this spot on my local computer:

Hope this helps!
Marisa
P.S. Sorry about the flag, the system can be too overzealous when people copy paste code in!