Skip to content
Advertisement

How to read most recent file with Pandas? Output path is undefined?

I’m trying to read the two latest sheets in my folder READ1 and READ2 with pandas. Usually when I read files the file name has to be formatted at 'File.xlsx' but the method I’m using is printing in the terminal as File.xlsx. I tried changing the format with:

JavaScript

Which outputs as ["'None'"]

My Code:

JavaScript

If I run my code as is I get

JavaScript

I have tried changing them to csv files too but that doesn’t change anything. I think Python is reading it as an undefined variable. Such as:

JavaScript

has the error:

JavaScript

I have been referenceing: How to get the latest file in a folder? https://datatofish.com/latest-file-python/

Advertisement

Answer

The print method just prints its arguments to the terminal and returns None, so READ1 and READ2 are None.

Replace:

JavaScript

with:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement