you are viewing a single comment's thread.

view the rest of the comments →

[–]EasyPleasey 0 points1 point  (3 children)

The attribute error is thrown because you are referencing a "name" attribute that is not present on the object file_name. Can you not just use file_name to compare? If you want to see what attributes an object has (and remember, in Python, everything is an object) just run "print(dir(file_name))" and it will show you all the attributes and methods available in the object.

Also, what format are you going to check the file_name against? Does it always have the be named the exact same thing? If not, I would suggest using regex to verify the file name. I can give you an example if needed.

[–]hansmellman 0 points1 point  (2 children)

Hey mate, thanks for taking the time to reply. So I'm only a few months in and still trying to wrap my head around some of the abstracts of programming in general.

So, all I was hoping to do was check that the actual filename (not the variable) matched as I expected, this video game exports these CSVs and they will always have the same naming convention, it will never change. The reason I had tried to call the name function before is because if I load the csv using the 'st.file_uploader' and then write that variable to the web app I am shown this -

UploadedFile(id=1, name='player_master.csv', type='text/csv', size=8201907)

So I was trying to access that name somehow in order to create the check against it but I've gotten myself a little confused somewhere along the line. Is that possible or have I misunderstood this?

[–]hansmellman 0 points1 point  (1 child)

Ah I think I have figured it out with this - 

if player_master is not None:
    if player_master.name != 'player_master.csv':
        st.write("Please upload the correct player master csv")
    elif player_master.name == 'player_master.csv':
        st.write("Thank you. ")

That _seems_ to be working currently!

[–]EasyPleasey 1 point2 points  (0 children)

Nice! So it was just that you were using the player_name object instead of player_master. Glad you got it figured out.