--- date: 2022-12-26 16:48 modification date: Monday 26th December 2022 16:48:45 title: "progress" aliases: [progress] --- # progress ## Progress Graph ```run-python pre import os import re from datetime import datetime import pandas as pd import matplotlib.pyplot as plt import seaborn as sns results = pd.DataFrame(columns=['date', 'count']) # Recursively walk through the directory and search for strings def search_directory(directory): date_counts = {} # Find all markdown files in the directory and its subdirectories files = [os.path.join(root, file) for root, dirs, files in os.walk(directory) for file in files if file.endswith('.md') if not "IW-Queue" in root] # Initialize counter for total number of strings found total_count = 0 # Iterate over all markdown files for file in files: with open(file, 'r') as f: contents = f.read() matches = re.findall(r"\u2705\s(\d{4}-\d{2}-\d{2})", contents) for match in matches: date = datetime.strptime(match, '%Y-%m-%d') if date not in date_counts: # Initialize count for this date date_counts[date] = 1 else: # Increment count for this date date_counts[date] += 1 return date_counts directory = "/home/zack/SparkleShare/github.com/Notes/Obsidian" # Run the search on the desired directory counts = search_directory(directory) df = pd.DataFrame(list(counts.items()), columns=['date', 'count']).sort_values(by='date') df['cumulative_total'] = df['count'].cumsum() sns.set_theme(style="darkgrid") # Create the plot sns.lineplot(x='date', y='cumulative_total', data=df) # Set the x-axis label plt.xlabel('Date') # Set the y-axis label plt.ylabel('Review items (total)') # Set the title plt.title('Cumulative Review Items') # Rotate to make dates readable plt.xticks(rotation=45, fontsize=6) # Show the plot plt.show() df["Increment"] = df["count"].diff(periods=2).fillna(0) # Create the plot sns.lineplot(x='date', y='count', data=df) # Set the x-axis label plt.xlabel('Date') # Set the y-axis label plt.ylabel('Number of tasks') # Set the title plt.title('Tasks completed each day') # Rotate to make dates readable plt.xticks(rotation=45, fontsize=6) # Show the plot plt.show() print(df.to_string()) ```