August 26, 2019
No, I didn’t. I wrote a much more boring program. But read on.
Reading on a Kindle is great. It’s easier to hold than a paperback. No bending books. It has a backlight, so I can read in the dark. It’s light, even if I’m reading a massive book.
Most importantly, I can make highlights and take notes as I’m reading very quickly, without ruining a printed book.
The highlights just sit on my Kindle and I can’t access them in one central place.
You might know about my Reading List. It’s a database on Notion of every book I’ve ever read. Where I’ve taken the time to add them, it includes notes and highlights from the book. The problem: I have forty books that I’ve read on Kindle—thousands of highlights—but they’re not in the database.
I exported all my notes in .HTML from the Kindle for macOS app. I put them all in one folder along with my Python script (even though there are better ways to do this.) Then I run the script, and it gives me a new set of plaintext files that are formatted so my Reading List database in Notion can understand it.
Simple. Sort of.
Why not just export from Kindle into Notion? When you export highlights from Kindle, unfortunately the formatting gets all fucked up. To fix it, I’d have to go through every file and manually edit them. My Python script fixes that.
The HTML files are also messy—because of all the HTML code. My program cleans them up and only returns the text, which is the part I want.
Here’s the program, if you’re interested in it:
This is what Kindle gives me upon export:
(This is the HTML behind that:)
This is what my Python script gives me:
Which ends up looking like this:
I didn’t write this so that you could download my program and use it. Unless you want to and know how, in which case, go for it.
I’m not a programmer. I only know enough Python to make some tasks a little easier for myself.
Case in point, it took me ~6 days of programming for 1–2 hours after work to finish this program. I could have hired someone on a site like TaskRabbit to help me clean up all these notes, but the point wasn’t efficiency.
The point was that I’ve spent weeks on end in front of my work computer in InDesign, Illustrator, and Photoshop. To keep myself challenged and excited about different things, I have to take on new challenges, such as this little programming project.
It’s another sandbox. And I loved working on this. Again, the code is amateur, but I solved so many problems in the process. I learned about the BeautifulSoup library, reminded myself how for loops worked, practiced my regex skills, used ViM like a semi-pro, and in the process had a lot of fun. I was staying up super late to work on this, which means it kept me stimulated and excited.
I truly cannot ask for any more than that.