Amazon stores all of your kindle highlights and notes in a txt file called "My Clippings.txt". Amazon will also let you export those highlights as a CSV file. ClippingsPluck accepts a string read from one of those files and returns an array of hashes.
Add this line to your application's Gemfile:
gem 'clippings_pluck'
And then execute:
$ bundle
Note: this is the preferred way to interact with ClippingsPluck. The Kindle CSV file is much more reliable and straightforward to parse than the TXT file.
First, read from the csv file:
string = File.open("clippings.csv", "rb").read
Then, you can pass that string into ClippingsPluck like this:
ClippingsPluck::CsvParser.new.run(string)
You'll get back an array of hashes, each of which might look something like this:
{
note: nil,
quote: '"He was not no machine!" screamed Gloria, fiercely and ungrammatically.',
author: "Isaac Asimov",
book_title: "I, Robot (The Robot Series Book 1)",
page: nil,
location: "245",
date: nil
}
Using the TXT file parser is similar:
file = File.open("./My\ Clippings.txt", "rb")
contents = file.read
Then, you can feed the string to ClippingsPluck like this:
ClippingsPluck::TxtParser.new.run(contents)
You'll get back an array of hashes, each of which might look something like this:
{
note: nil,
quote: '"He was not no machine!" screamed Gloria, fiercely and ungrammatically.',
author: "Isaac Asimov",
book_title: "I, Robot (The Robot Series Book 1)",
page: nil,
location: "245",
date: "Tuesday, November 22, 2017 6:42:51 PM"
}
Q: How do I get ahold of these highlight files?
A: Follow the instructions here.
The gem is available as open source under the terms of the MIT License.