I’m trying to make a habit tracker using some Obsidian plugins, but for that of course I need the data!
The idea is that I make a new Task List Account on Evolution for everything I want to track, like exercise or hours of sleep, which is synchronized to my phone through DecSync, so that I can use a widget on my phone with Tasks.org to easily insert new data.
Now, that means that it makes no sense to manually export the Task List as a CSV dataset, since it is constantly up-to-date on my computer.
The problem I’m facing is transforming the ICS dataset to a CSV. At first I tried it “the long way”, opening the ICS file with LibreOffice Calc and exporting it to a CSV file, which worked, and now I’m trying to do it with a Python script…
I tried two different ways. The one mentioned here, where I had to run
pip install csv-ical, create a Python file on the folder where my data is with the following code:
from csv_ical import Convert # Create and initialize a Convert object convert = Convert() convert.CSV_FILE_LOCATION = 'my_file.csv' convert.SAVE_LOCATION = 'my_file.ics' # Read the .ics file convert.read_ical(convert.SAVE_LOCATION) # Create the CSV object and save it at the specified location convert.make_csv() convert.save_csv(convert.CSV_FILE_LOCATION)
And run it.
The second method I tried was creating a Python file with this script:
import vobject import csv with open('Ola.csv', mode='w') as csv_out: csv_writer = csv.writer(csv_out, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) csv_writer.writerow(['WHAT', 'FROM', 'TO', 'DESCRIPTION', 'LOCATION']) # read the data from the file data = open("tasks.ics").read() # iterate through the contents for cal in vobject.readComponents(data): for component in cal.components(): if component.name == "VEVENT": writerow =  for attr in ['summary', 'dtstart', 'dtend', 'description', 'location']: if hasattr(component, attr): writerow.append(getattr(component, attr).valueRepr()) else: writerow.append('Undefined!') print(writerow) csv_writer.writerow(writerow)
And run it.
I don’t know if the problem is that those scripts were written for Calendars instead of Task Lists, but I only get empty documents when I run the scripts (though on the second one I do get the headers).
Now the question: Does anybody know how to effectively transform ICS Task Lists into CSV files?
Thanks a lot!