1
I am trying to return the path and modification date of all files in a folder, but I am not able to return the date, only the path.
code so far:
from pathlib import Path
import pandas as pd
data_modificacao = lambda f: f.stat().st_mtime
directory = Path('path')
files = directory.rglob('*.*')
sorted_files = sorted(files, key = data_modificacao, reverse = True)
pathdf = list(sorted_files)
pathdf = pd.DataFrame(pathdf)
pathdf.rename(columns = {0:'path'}, inplace = True)
pd.set_option('max_colwidth', None)
pathdf.head(10)
the output is a Dataframe ordered by the modification date, but only with the path column... how do I return, also, a column with the modification date?
very good, it worked! , another solution I found, using my code, would be to create a Dataframe with the date from the sorted_files and then merge with the Dataframe already created for the path, so the date column would not have the stat() formatting. st_mtime next to datetime.
– Victor