Skip to content

Instantly share code, notes, and snippets.

@yatharthb97
Created August 18, 2023 16:18
Show Gist options
  • Save yatharthb97/65f6c5207e9c484597e6e5e24db3ea88 to your computer and use it in GitHub Desktop.
Save yatharthb97/65f6c5207e9c484597e6e5e24db3ea88 to your computer and use it in GitHub Desktop.
Plots a graph of the creation time (milliseconds) of all files in a folder.
import os
from datetime import date
import datetime
import matplotlib.pyplot as plt
def file_timestamp_graph(dir_="."):
all_files = list(os.listdir(dir_))
all_files.sort()
# Get creation time of each file
times = [os.path.getctime(file) for file in all_files]
return times
# Parse ISO time format
isostamps = [date.fromisoformat(file) for file in times]
# Parse to millisecond tick
ms_ticks = [datetime.timestamp(iso) for iso in isostamps]
return ms_ticks
if __name__ == "__main__":
stamps = file_timestamp_graph()
x = [i for i in range(len(stamps))]
plt.xlabel("Files")
plt.ylabel("Creation time in milliseconds")
plt.plot(x, stamps)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment