t %}
How to export Kobo highlights to WorkFlowy
Highlight on my Kobo Aura

How to export Kobo highlights to WorkFlowy

2020-07-16

My whole life goes into WorkFlowy. I have a diary there, all my to-do’s, grocery lists, notes, everything. And although you could read books in WorkFlowy, I prefer the comfort of an e-reader. Especially when traveling and offline for days at a time. When reading, I sometimes take notes straight into WorkFlowy on my phone, but it’s often more convenient to select a piece of text and add a highlight. But where do those highlights go? And how do you get them out?

Turns out there are a couple of things you can do to get your highlights from your Kobo into someplace else:

  1. You could export them to Calibre using the Annotations plugin.
  2. You could add these lines to /.kobo/Kobo/Kobo eReader.conf on your Kobo to get the option to export a book’s highlights to a text file straight from the e-reader:
      [FeatureSettings]
      ExportHighlights=true
    
  3. But because I did not want to end up having them stuck in Calibre, nor having to go through all the books I’ve read one by one, I chose to access my Kobo Aura’s database directly.

Accessing my Kobo’s SQLite database

Kobo SQLite Database

I first explored /.kobo/KoboReader.sqlite using the open source DB Browser for SQLite. This led me to a table called Bookmark, which contains all my highlights, annotations and bookmarks. I then wrote a database reader in Python to access all that data and convert it into a pandas DataFrame for easy cleanup.

Cleaning up these highlights and bookmarks

Kobo SQLite Database

Highlights (selecting text) and bookmarks (folding the corner of the page) are not stored in the same way in that database, so I had to write some rules to clean everything up into something I would want to import into WorkFlowy:

Highlights

Highlights have the selected text in the Text field and references to where in the ebook that text came from in StartContainerPath and EndContainerPath. I chose to also include DateCreated in my output, as well as parse the folder and file name structure (as generated by Calibre) into author and title information.

Bookmarks

Bookmarks do not have anything in the Text field, just a reference to the bookmarked page in ExtraAnnotationData.

Annotations

If you add your own notes to your ebooks as well, you might want to take a look at the Annotations field.

Importing the result into WorkFlowy

Unfortunately WorkFlowy does not have an API yet, so we’ll have to make do with pasting plain text into a bullet. To do so, I wrote a loop that outputs all my highlights to a string with new lines (\n) starting with dashes and proper indenting with tabs (\t). I then print this to my console and copy and paste it into WorkFlowy. Et voila:

Kobo SQLite Database

Ready to try it yourself? All of my work—except for the actual database of highlights—is on GitHub.