Quotebook to HTML

I am a voracious hoarder of quotations. As I read, I tend to jot them down in my Field Notes notebook and then (usually) type them into Quotebook. It's a well designed and convenient app for collecting such things.

But sometimes I don't want to view my quotes individually. I may want to, say, see every quote by a specific author at once. Quotebook doesn't have a UI for this, but it does let you export all of your quotes into a friendly csv formatted file1. So I wrote a Python script to take that file and turn it into HTML, grouping the quotes alphabetically by author2:

import csv

quotes = []

with open('Quotes.csv', 'rb') as csvfile:
    quotes_file = csv.reader(csvfile)
    for row in quotes_file:

authors = set([a[1] for a in quotes if a[1] != ' '])
authors = list(authors)

grouped_quotes = {a:[] for a in authors}

for author in authors:
    for quote in quotes:
        if quote[1] == author:
            grouped_quotes[author].append((quote[0], quote[2]))

out = """<html>

for author in authors:
    out += "<h2>%s</h2>" % author
    for quote in grouped_quotes[author]:
        out += """
            """ % quote

out += """

with open('quotes.html', 'w') as outfile:

Is there a better, more Pythonic way of doing it? I guarantee it. But I need to maintain my reputation as a total hack....

  1. Unfortunately, Quotebook only gives you two export options: email or iTunes sharing. So right now getting the data file somewhere useful is a bit of a manual process. Maybe one day they'll add a Dropbox export option and then you could hook the script up to Hazel.  

  2. Unattributed quotes are not included, but you can change that by editing the list comprehension in line 10 to authors = set([a[1] for a in quotes]) if you like. 

Share on App.net

Comments !