Python Forum
help with accessing .txt file and performing actions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with accessing .txt file and performing actions
#5
Quote:To find out if the task is overdue
To do this in pandas.
import pandas as pd
from datetime import datetime

tasks = pd.read_csv(
    "tasks.txt",
    sep=";",
    names=["user", "action", "desc", "created", "due", "complete"],
    parse_dates=["due", "created"])
tasks.complete = tasks.complete=="Yes"

print("All tasks", tasks, sep="\n")
print("\nAwaiting completion")
print(tasks[~tasks.complete])
today = datetime.strptime("2024-06-15", "%Y-%m-%d")
print("\nOverdue\nToday =", today.strftime("%Y-%m-%d"))
print(tasks[(~tasks.complete) & (tasks.due < today)])
Output:
All tasks user action desc created due complete 0 am needs doing now 2004-04-12 2024-03-05 False 1 sam please do gym 2024-05-20 2024-07-05 False 2 admin do sd 2004-12-12 2024-05-05 False 3 dam dam dam 2024-12-12 2024-03-05 True Awaiting completion user action desc created due complete 0 am needs doing now 2004-04-12 2024-03-05 False 1 sam please do gym 2024-05-20 2024-07-05 False 2 admin do sd 2004-12-12 2024-05-05 False Overdue Today = 2024-06-15 user action desc created due complete 0 am needs doing now 2004-04-12 2024-03-05 False 2 admin do sd 2004-12-12 2024-05-05 False
Reply


Messages In This Thread
RE: help with accessing .txt file and performing actions - by deanhystad - Mar-07-2024, 07:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Timing actions with Python dangermaus33 0 1,026 Apr-19-2022, 10:08 PM
Last Post: dangermaus33
  Loop different actions for an array Tibovdv 4 2,786 Mar-25-2021, 06:46 PM
Last Post: jefsummers
  One-time actions when iterating ClassicalSoul 1 1,756 Apr-23-2020, 07:39 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020