-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
640e79f
commit cbda082
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import datetime | ||
import csv | ||
|
||
def load_tasks(filename='tasks.csv'): | ||
tasks = [] | ||
with open(filename, 'r', newline='') as file: | ||
reader = csv.reader(file) | ||
for row in reader: | ||
tasks.append({'task': row[0], 'deadline': row[1], 'completed': row[2]}) | ||
return tasks | ||
|
||
def save_tasks(tasks, filename='tasks.csv'): | ||
with open(filename, 'w', newline='') as file: | ||
writer = csv.writer(file) | ||
for task in tasks: | ||
writer.writerow([task['task'], task['deadline'], task['completed']]) | ||
|
||
def add_task(task, deadline): | ||
tasks = load_tasks() | ||
tasks.append({'task': task, 'deadline': deadline, 'completed': 'No'}) | ||
save_tasks(tasks) | ||
print("Task added successfully!") | ||
|
||
def show_tasks(): | ||
tasks = load_tasks() | ||
for task in tasks: | ||
print(f"Task: {task['task']}, Deadline: {task['deadline']}, Completed: {task['completed']}") | ||
|
||
# Example usage | ||
add_task('Write daily report', '2024-04-20') | ||
show_tasks() |