This project retrieves, processes, and enriches highlights from your Readwise account, generating both CSV and DOCX files that include the highlights and associated tags. If the highlights have fewer than 3 tags, the script uses OpenAI to generate additional relevant tags.
- Fetches all highlights from a user's Readwise account, iterating through multiple pages of data if necessary.
- Automatically enriches highlights with additional tags generated by OpenAI if fewer than three are present.
- Saves highlights with their tags to both a CSV and DOCX file.
- Logs updated highlights and handles potential errors, such as API rate-limiting.
- Supports pagination to retrieve large datasets beyond a single API request limit.
.gitignore
: Specifies files and directories to be ignored by Git.Highlights_with_Tags.csv
: CSV file containing highlights with tags.Highlights_with_Tags.docx
: DOCX file containing highlights with tags.Highlights.docx
: DOCX file containing highlights without additional tags.README.md
: This file, explaining project details.readwise.py
: Python script responsible for fetching, processing, and saving highlights.requirements.txt
: List of dependencies required for the project.updated_highlights_log.txt
: Log file recording the highlights that were successfully updated in Readwise with new tags.
-
Clone the repository:
git clone https://github.com/your-username/highlights-project.git cd highlights-project
-
Install the required dependencies:
pip install -r requirements.txt
-
Set Environment Variables: You will need two environment variables:
READWISE
: Your Readwise API token.OPENAI_API_KEY
: Your OpenAI API key.
You can set them like this in your terminal:
export READWISE=your_readwise_token export OPENAI_API_KEY=your_openai_api_key
-
Run the
readwise.py
script to process highlights:python readwise.py
-
Output Files:
Highlights_with_Tags.csv
: CSV file with highlights and their tags.Highlights_with_Tags.docx
: DOCX file with highlights and their tags.updated_highlights_log.txt
: Log of successfully updated highlights in Readwise.
- API Rate-Limiting: The script detects API throttling errors and logs when requests are delayed due to rate limits. You may need to rerun the script after waiting for the cooldown period.
- Incomplete Tag Generation: If the OpenAI tag generation fails, it logs the error and continues processing other highlights.
This project uses the following Python packages:
stack-data==0.6.3
tornado==6.4
tqdm==4.66.4
traitlets==5.14.2
typing_extensions==4.12.2
tzdata==2024.1
urllib3==2.2.2
wcwidth==0.2.13
requests==2.28.1
python-docx==0.8.11
openai==1.7.0
You can install them by running:
pip install -r requirements.txt
This project is licensed under the MIT License. You are free to use, modify, and distribute this project under the terms of the license.