Whatever is assigned to the files
variable is incorrect. Use the following code.
import glob
import os
list_of_files = glob.glob('/path/to/folder/*') # * means all if need specific format then *.csv
latest_file = max(list_of_files, key=os.path.getctime)
print(latest_file)
Related Contents:
- How can I read inputs as numbers?
- Using both Python 2.x and Python 3.x in IPython Notebook
- What do ellipsis […] mean in a list?
- Behavior of exec function in Python 2 and Python 3
- Local variable referenced before assignment?
- Python Variable Declaration
- Extracting text from a PDF file using PDFMiner in python?
- Integer division in Python 2 and Python 3
- Why is a list comprehension so much faster than appending to a list?
- How to use pip with Python 3.x alongside Python 2.x
- Why is parenthesis in print voluntary in Python 2.7?
- How to print a string at a fixed width?
- Cleanest way to get last item from Python iterator
- Why does str(float) return more digits in Python 3 than Python 2?
- How to extract text from an existing docx file using python-docx
- Getting only element from a single-element list in Python?
- What’s the difference between __builtin__ and __builtins__?
- Most pythonic way to interleave two strings
- How can I convert 24 hour time to 12 hour time?
- operator.itemgetter or lambda
- How can I make a for-loop pyramid more concise in Python? [duplicate]
- Backporting Python 3 open(encoding=”utf-8″) to Python 2
- Using multiple Python engines (32Bit/64bit and 2.7/3.5)
- Could not find a version that satisfies the requirement tensorflow
- Why does this not work as an array membership test? [duplicate]
- How to Install and Use TkDnD with Python Tkinter on OSX?
- How to print a list with integers without the brackets, commas and no quotes? [duplicate]
- Argparse with required subparser
- How to create a Python dictionary with double quotes as default quote format?
- rounding errors in Python floor division
- Search for a value in a nested dictionary python
- Is Python’s order of evaluation of function arguments and operands deterministic (+ where is it documented)?
- What is a clean way to convert a string percent to a float?
- How do I run python 2 and 3 in windows 7? [duplicate]
- Using Properties in Python classes cause “maximum recursion depth exceeded” [duplicate]
- ValueError: malformed string when using ast.literal_eval
- Python3 correct way to import relative or absolute?
- How to apply a function to each sublist of a list in python?
- How to get Windows short file name in python?
- How does a for loop evaluate its argument
- How to use collections.abc from both Python 3.8+ and Python 2.7
- Python 3 urllib produces TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str
- What does the slice() function do in Python?
- Skip elements on a condition based in a list comprehension in python
- ‘is’ operator behaves unexpectedly with floats
- Converting string to tuple without splitting characters
- Sound generation / synthesis with python?
- How to read the last line of a file in Python? [duplicate]
- WinError 2 The system cannot find the file specified (Python)
- Calling Python script from C++ and using its output