PythonGanttChart

Gantt Chart

Here's an example of a Gantt chart created using Matplotlib (Bing Copilot generated source code).

In [2]:
import matplotlib.pyplot as plt

# Define task names and their corresponding start and end dates
tasks = {
    'Task 1': (1, 5),
    'Task 2': (6, 15),
    'Task 3': (16, 25),
    'Task 4': (26, 35),
    'Task 5': (36, 45),
    'Task 6': (46, 55),
    'Task 7': (56, 65)
}

# Create figure and axis objects
fig, ax = plt.subplots(figsize=(10,5))

# Set x-axis limits
start_date = min([tasks[task][0] for task in tasks])
end_date = max([tasks[task][1] for task in tasks])
ax.set_xlim([start_date - 1, end_date + 1])

# Set y-axis limits
ax.set_ylim([0.5,len(tasks)+0.5])

# Set y-axis labels
ax.set_yticks(range(1,len(tasks)+1))
ax.set_yticklabels(list(tasks.keys()))

# Plot horizontal bars for each task
for i,(task,(start,end)) in enumerate(tasks.items()):
    duration = end - start
    ax.broken_barh([(start,duration)], (i+0.1,.8))

# Set x-axis label and title
ax.set_xlabel('Date')
ax.set_title('Project Schedule')

plt.show()
In [ ]:
 

CSV TODO

Example of CSVTODO csv file below.

In [3]:
import csv
todocsv = """id,status,priority,project,description,context,start date,due date,annotation
3,,,+LibreOffice,Task 1,,2022-06-21,2022-06-26,
4,,,+LibreOffice,Task 2,,2022-06-24,2022-06-28,
5,,,+LibreOffice,Task 3,,2022-06-26,2022-06-30,
6,,,+LibreOffice,Task 4,,2022-06-29,2022-07-08,
7,,,+LibreOffice,Task 5,,2022-06-18,2022-07-13,
"""
In [4]:
import io
stream =  io.StringIO(todocsv)
tasks = csv.reader(stream)
In [5]:
# csv reader to list
taskslist = []
for task in tasks:
    taskslist.append(task)
In [6]:
taskslist
Out[6]:
[['id',
  'status',
  'priority',
  'project',
  'description',
  'context',
  'start date',
  'due date',
  'annotation'],
 ['3', '', '', '+LibreOffice', 'Task 1', '', '2022-06-21', '2022-06-26', ''],
 ['4', '', '', '+LibreOffice', 'Task 2', '', '2022-06-24', '2022-06-28', ''],
 ['5', '', '', '+LibreOffice', 'Task 3', '', '2022-06-26', '2022-06-30', ''],
 ['6', '', '', '+LibreOffice', 'Task 4', '', '2022-06-29', '2022-07-08', ''],
 ['7', '', '', '+LibreOffice', 'Task 5', '', '2022-06-18', '2022-07-13', '']]
In [7]:
import json
import pyperclip as clip
f_tasks = ['id','status','priority','project','name','context','start','end','notes']
tododata = [dict(zip(f_tasks,task)) for task in taskslist]
tododata.pop(0)
s = json.dumps(tododata,indent=4)
# Copy to the clipboard the JSON formatted todo list 
clip.copy(s)
print (s)
[
    {
        "id": "3",
        "status": "",
        "priority": "",
        "project": "+LibreOffice",
        "name": "Task 1",
        "context": "",
        "start": "2022-06-21",
        "end": "2022-06-26",
        "notes": ""
    },
    {
        "id": "4",
        "status": "",
        "priority": "",
        "project": "+LibreOffice",
        "name": "Task 2",
        "context": "",
        "start": "2022-06-24",
        "end": "2022-06-28",
        "notes": ""
    },
    {
        "id": "5",
        "status": "",
        "priority": "",
        "project": "+LibreOffice",
        "name": "Task 3",
        "context": "",
        "start": "2022-06-26",
        "end": "2022-06-30",
        "notes": ""
    },
    {
        "id": "6",
        "status": "",
        "priority": "",
        "project": "+LibreOffice",
        "name": "Task 4",
        "context": "",
        "start": "2022-06-29",
        "end": "2022-07-08",
        "notes": ""
    },
    {
        "id": "7",
        "status": "",
        "priority": "",
        "project": "+LibreOffice",
        "name": "Task 5",
        "context": "",
        "start": "2022-06-18",
        "end": "2022-07-13",
        "notes": ""
    }
]
In [ ]:
 
In [ ]: