CS50P Final Project
KDP Tracker
Video Demo: https://youtu.be/0qZjCObs3eU
Description:
An easy to use Python program for managing KDP reports by uploading them to a SQL database and then allowing the user to visualize a Sales/Earnings chart.
Features
- Import KDP Reports (.xlsx)
- Create SQL database from KDP Reports
- Track unit sales over time:
- eBook
- KENP
- Free
- Paperback
- Hardback
- Audio Book
- Track Royalties over time
- Display in easy to read chart
- Filter by:
- Start Date range
- End Date range
- Book title
- Publication Format
How to Use
Library Requirements
- PyQt5
- pandas
- sqlalchemy
- matplotlib
KDP Reports/KDPTracker database
- Run the program from within a python environment.
- It will initialize the KDPtracker database (if one does not already exist).
- Upload all the KDP Reports you want to store in the database (bottom right button)
- “Books” section on the left panel will automatically populate based on the unique titles within the database.
KDPTracker Filters
- “Start Date:” will automatically default to 1/1/YYYY (current year).
- Change this to whichever month you want to filter by
- “End Date:” will automatically default to (current day).
- Change this to whichever month you want to filter by
- The KDPTracker database stores records by YYYYMM (as that’s how it come from KDP Reports), so leave the day of the month as the 1st.
- “Books:” section is selectable one-by-one or
ctl + a
to select all titles. - “Format:” section is selectable one-by-one or
ctl + a
to select all formats. - “Run” when you’ve selected the books you want to look up, and the formats you want to check, push “Run” and the Sales/Earnings chart will automatically populate.
KDPTracker Chart
- X-axis is by months/year (it’s recommended to view 12 months max, but there’s no limit)
- Left Y-axis is “net units sold/KENP reads” and corresponds to the height of the blue bar graph.
- Right Y-axis is “royalties” and corresponds to the dots of the orange line graph.
Design Breakdown
KDP Tracker opperates as two files: project.py and kdptracker.db.
Upon first running project.py the program will use PyQT5 to create the GUI.
class KDPTracker(QWidget):
def __init__(self):
super().__init__()
self.settings()
self.initUI()
I chose PyQt5 as a result of stumbling upon Code With Josh as he built a fitness tracker, which used a SQL database and matplotlib to track data and then display a chart. Going into this project, I knew the basics of what I wanted to accomplish (import xlsx, create database, display charts similar to KDP user dashboard), but only after seeing what Josh did, did I understand the libraries I needed.
Why make this program?
The KDP Reports dashboard only allows filtering by past 90 days and lifetime, which this program aims to solve. Compiling all the KDP reports into a single SQL database also makes it easier to save and backup moving forward.
My main objective was to get hands on experience creating a functional piece of software that solved a real world issue, and was not just a carbon copy of an already existing application. I’m confident this checks that box, though it’s not in a “commercially” viable state, it’s built well enough for my personal use moving forward.
Future Features
- Create an export function to save reports as PDFs.
- Create a conditional function that filters for KENP and splits it into it’s own bar graph.
- Integrate an API to convert foreign currencies into USD.
- Create a pi graph function that breaks down royalties by format type.
- Create an “author” filter to change the “books” section to only populate based on the selected author.
Electron
If I circle back around to this program for further development, I think starting over from scratch and building it in Electron is my best move. The options I’ve discovered for converting Python programs into .exe applications leave a lot to be desired. Election offers the ability to use the program on all three desktop environments, at the cost of learning JavaScript (which is a recommended language anyways).
Given the community around JS, I’m confident I would discover similar libraries to handle the charting and file importing/exporting; which are the core functions of the application.