Skip to main content

Clippy is a Python package for parsing Kindle's `My Clippings.txt` file.

Project description

Clippy

Clippy is a Python package for parsing Kindle's My Clippings.txt file. It extracts useful information such as the title, author, page number, Kindle locations, date added, and highlighted text, making it easier to analyze and organize your Kindle highlights.

Features

  • Parse Kindle's My Clippings.txt file into structured data.
  • Extract the following fields:
    • title_author: Title and author of the work the clipping is from.
    • page: Page number of the clipping (if available).
    • start_location: Starting Kindle location of the clipping.
    • end_location: Ending Kindle location of the clipping.
    • date_added: Date the clipping was added.
    • text: Highlighted text from the clipping.
  • Supports handling empty or malformed clippings gracefully.
  • Save parsed clippings to a CSV file.

Requirements

  • Python >= 3.10

Installation

Clone the repository:

git clone https://github.com/yourusername/clippy.git
cd clippy

Usage

Programmatic Usage

You can use Clippy as a library in your Python code:

from clippy.Clipping import Clipping, Clippings

# Parse a single clipping
raw_clipping = """Book Title (Author Name)
- Your Highlight on page 45 | location 678-680 | Added on Thursday, January 1, 2023
This is the highlighted text."""
clipping = Clipping(raw_clipping)
print(clipping.title_author)  # Output: Book Title (Author Name)
print(clipping.text)          # Output: This is the highlighted text.

# Parse multiple clippings and save to CSV
clippings = Clippings()
clippings.add_clipping(clipping)
clippings.save_to_csv("output.csv")

Example Script

You can also create your own script to parse and save clippings. For example:

from clippy.Clipping import Clipping, Clippings

# Load raw clippings from a file
with open("data/My Clippings.txt", "r", encoding="utf-8") as file:
    raw_clippings = file.read().split("==========")

# Parse clippings
clippings = Clippings()
for raw_clipping in raw_clippings:
    if raw_clipping.strip():  # Skip empty clippings
        clippings.add_clipping(Clipping(raw_clipping))

# Save to CSV
clippings.save_to_csv("data/My Parsed Clippings.csv")
print("Clippings saved to data/My Parsed Clippings.csv")

Project Structure

clippy/
├── src/
│   └── clippy/
│       ├── __init__.py
│       ├── Clipping.py       # Contains the Clipping and Clippings classes
├── data/
│   └── My Clippings.txt      # Example input file
├── examples/
│   └── example.py            # Example usage of the library
├── tests/
│   └── test_clipping.py      # Unit tests for Clipping and Clippings classes
└── README.md                 # Project documentation

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kindle_clippy-0.0.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kindle_clippy-0.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file kindle_clippy-0.0.1.tar.gz.

File metadata

  • Download URL: kindle_clippy-0.0.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.1

File hashes

Hashes for kindle_clippy-0.0.1.tar.gz
Algorithm Hash digest
SHA256 313d8aa4ac6fe671bc9b5c375fcdca8c45d194b3278c3d1c50038982ce3e04eb
MD5 3f6bee90fa2419bce3acebd0b3779563
BLAKE2b-256 09838bb3755ec5f862bf3f855328c8cbf85ed84f92cfecb8df6ae68a5b2bacf3

See more details on using hashes here.

File details

Details for the file kindle_clippy-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: kindle_clippy-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.1

File hashes

Hashes for kindle_clippy-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 81a45e2c4fa277a5ab5f8e9284e57375623cb4957f5a545464d374f90a61066f
MD5 f76f6308b24b13275b162ad5676efc01
BLAKE2b-256 04fcb572bd17e88f17913188dcde3243f2237e1318ed624da248ab7dcc3dcb1d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page