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

pip install kindle_clippy

Usage

Programmatic Usage

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

from clippy 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 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.2.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.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kindle_clippy-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 486f3188e9207e1dcf58fdc6a976f06c5f4f27dd102b77c05267534befc61d0b
MD5 5982ad52bbe6dfc1681e49aea1ba8b1a
BLAKE2b-256 f9507f382868249ffe4c990d03bfda8ea890cbd98c8b0bab896dcf5c1bad586d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kindle_clippy-0.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e3576047c9e2883a3061230917a13fb2665b9e78a3d9afb7b1be00507603963f
MD5 ea23912b9c0aa148f55d46bea2a59569
BLAKE2b-256 88589d0e417323a27b5a5fae7376d51d2d72cff1c322a9147012ced1f9bbd5cb

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