I'm connected to Azure Storage and needs to get the name of a file. I have written a function which gets the list of contents in a particular directory.
datepath = np.datetime64('today').astype(str).replace('-', '/')
def list_directory_contents():
try:
file_system_client = service_client.get_file_system_client(file_system="container_name")
paths = file_system_client.get_paths(path = "folder_name/" + str(datepath))
for path in paths:
print(path.name + '\n')
except Exception as e:
print(e)
And then I'm calling the function
list_directory_contents()
This gives me the something like
folder_name/2020/10/28/file_2020_10_28.csv
Now I want to extract just the file name from the above i.e. "file_2020_10_28.csv"