Transforming Evolution Tasks ICS to CSV

Hello everyone!

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!

Hi,
they are called VTODO. The properties are also different. I suggest you
create a new test task in Evolution, fill all the information you’d
like to have synchronized and then right-click the task and pick “Save
as iCalendar…”. After that open the saved file and check its content.
Everything between BEGIN:VTODO and END:VTODO is the stored information
about your task.

Are you sure you cannot have a direct access to the tasks.org task
list? Maybe they have a CalDAV interface, which you could use without
additional export/import. It would be much cleaner as well.
Bye,
Milan

1 Like

Have you considered using a proper, non-broken file format (that means not CSV)?

I see what you mean!

I was following your instructions but while creating the tasks for the training, I noticed that I cannot make subtasks on Evolution, while on Tasks is possible (only a little limited), and in Evolution the subtasks I add on Tasks appear as different tasks. But I think I can work around it with tags or something…

I was trying to find where Tasks keeps the data, so I asked here, and I was told that:

Tasks keeps it’s data in a private Sqlite db. DecSync will “sync” this data with ics files in your phone’s memory

I asked, and I was told that I would have to work with ICS files to use the Tasks data, but still no clue where the files are.

Still, I think the problem on how to get the data automatically from there to Obsidian is not solved (Obsidian uses Markdown syntax), so I’m thinking it is way too complicated to do it through Tasks. Maybe I’m wrong…

Thanks!

No, I haven’t considered it, since I’m by far no profi and I had no idea there are problems with CSV file format. Still I would appreciate if you told me one or more options to work with. And if you share some lights on why CSV is such a bad file format, I (and future readers) may also learn something.

I noticed that I cannot make subtasks on Evolution, while on Tasks is
possible (only a little limited), and in Evolution the subtasks I add
on Tasks appear as different tasks.

Hi,

you are right, Evolution does not support sub-tasks. There are no
relations between the tasks.

I was trying to find where Tasks keeps the data, so I asked here, and
I was told that:

Tasks keeps it’s data in a private Sqlite db. DecSync will “sync”
this data with ics files in your phone’s memory
I asked, and I was told that I would have to work with ICS files to
use the Tasks data, but still no clue where the files are.

I can be wrong, but it seems to me you are doing the things too
low-level, making it unnecessarily complicated. You shouldn’t touch
application files by any means - it’s a way to break things, not to
improve them, especially when you are not careful. After all, they are
application data. They can change formats every second day, which can
break your effort easily. You should use standard (and ideally stable)
API-s to get the data from/to the server. Then connect your devices to
the server, using the standard protocols, and that’s all. Do not fiddle
with internal application data.

Still, I think the problem on how to get the data automatically from
there to Obsidian is not solved (Obsidian uses Markdown syntax), so
I’m thinking it is way too complicated to do it through Tasks.

Markdown is not a problem, it’s a plain text, which can be interpreted
in some way, making it a fancy-looking text. It’s still readable by the
humans (in contrast to HTML, which is hard to decipher). Evolution does
support Markdown for the description since 3.46.x I think (the current
stable series is 3.48.x).
Bye,
Milan

1 Like

To start with, CSV doesn’t allow defining a character encoding. So you can easily get Mojibake between two systems.

You shouldn’t touch application files by any means

My plan was actually to copy the file to a different location and work with the copy… The thing is also that I don’t need to modify any data from the apps, just to get it, but I surely didn’t consider that the formats can change…

Markdown is not a problem, it’s a plain text, which can be interpreted in some way, making it a fancy-looking text. It’s still readable by the humans (in contrast to HTML, which is hard to decipher). Evolution does support Markdown for the description since 3.46.x I think (the current stable series is 3.48.x).

I know Markdown is super friendly, the problem I’m facing is to extract the data… I’ll try to get my head around APIs and APIs with Evolution, and I’ll post my experience…

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.