Feb-10-2023, 05:55 PM
OK, got you close -
Since numpy is a numerical oriented library, I decided to use Pandas.
Since numpy is a numerical oriented library, I decided to use Pandas.
import pandas as pd from todoist_api_python.api import TodoistAPI # Fetch tasks synchronously def get_tasks_sync(): api = TodoistAPI("XXXXXX") try: tasks = api.get_tasks() return tasks except Exception as error: print(error) tasklist = get_tasks_sync() itemlist = [] #start a list of the tasks for task_obj in tasklist: # recognize that you have a set of Task objects to convert to strings task = task_obj.__str__() # convert to a string item = task[5:-1] # Get rid of "Task(" item = item[0:-3] # Get rid of closing parens item = item.split(',') # Now split the string on commas into the individual fields itemlist.append(item) # Add this list of fields to the list of tasks df = pd.DataFrame(itemlist) #Turn it into a dataframe df.head() #show result