To find the name of a CSV file in Python, you can use the pathlib
module to get a Path
object for the file. Then you can use string manipulation functions to extract the name of the file from the path.
Assuming the CSV file is in the current working directory, you can use the following code:
main.py220 chars10 lines
If the CSV file is in a different directory, you can specify the full path when creating the Path
object.
gistlibby LogSnag