Parses CSV Export of patrons from patreon.com, allows extracting patrons pledging for reward levels provided on command line and rendering them to stdout using a provided jinja2 template file.
👉 Provided as-is. If it works for you, great, if it doesn't, please understand that I cannot provide any support and won't accept pull requests either.
Requires Python 3 and a bunch of dependencies:
pip3 install -r requirements.txt
Installation into virtualenv is recommended.
$ python patronexport.py --help
Usage: patronexport.py [OPTIONS]
Options:
-i, --input PATH The patron export from Patreon as .csv file
[required]
-o, --output PATH The output path
-t, --template PATH The template path of the Jinja2 template to use
[required]
-r, --reward TEXT The reward levels to include - textual name, case
insensitive
-d, --also-declined Also include declined patrons in output
-f, --from TEXT year-month-day of start date from which to output
patrons
-, --until TEXT year-month-day of start date until which to output
patrons
-m, --mapping PATH Mapping file from mail to replacement patron metadata
-a, --additional PATH Additional manually managed patrons, as yaml file of
CSV entries
--help Show this message and exit.
All patrons to output file:
patronexport.py -i Members_somenumber.csv -t mytemplate.md -o output.md
Only patrons at reward levels "One Tier" and "Another Tier" to stdout:
patronexport.py -i Members_somenumber.csv -t mytemplate.txt -r "One Tier" -r "Another Tier"
Only patrons at reward level "Another Tier" with mapping file to output file:
patronexport.py -i Members_somenumber.csv -t mytemplate.md -r "Another Tier" -m mappingfile.yaml -o output.md
Templates are Jinja2 templates.
Available template variables are:
patrons
: List of all included patrons asPatron
objectsincluded
: Count of all included patronsexcluded
: Count of all excluded patronstotal
: Total count of all patronsreward_levels
: List of included reward levels
A Patron
object has the following attributes:
name
: User name on Patreondisplay_name
: Name from mapping, or addressee, or nameemail
: Mail addresspledge
: Amount of pledgelifetime
: Amount of pledges already processedstatus
:ok
,declined
orformer
twitter
: Twitter handle without @street
: Street part of shipping addresscity
: City part of shipping addressstate
: State part of shipping addresszip
: Zip part of shipping addresscountry_code
: Country code part of shipping address (ISO3166)country
: Human readable version of country of shipping addressphone
: Phone numberstart
: Start of patronagestart_date
: Start of patronage as datetime object (parsed by dateutil)max
: Maximum monthly amount, or maybe posts? (unclear in Patreon export)tier
: Name of pledge tier (as set up on Patreon)following
: Whether the patron is following youcharge_frequency
: How often the user gets chargedlast_charge
: Date of last chargelast_charge_date
: Date of last charge as datetime object (parsed by dateutil)details
: Additional details (from Relationship Manager?)id
: User idlast_update
: Date of last update of user datalast_update_date
: Date of last update of user data as datetime object (parsed by dateutil)discord
: Discord handle of patroncurrency
: Currency of patronageaccess_expiration
: Value from "Access Expiration" column in CSV export, currently unknown format
Big thanks to
{% for patron in patrons | sort(attribute='display_name') %}
* {% if patron.twitter %}[{{ patron.display_name | trim() }}](https://twitter/{{ patron.twitter | trim() }}){% else %}{{ patron.display_name | trim() }}{% endif %} (since {{ patron.start }})
{% endfor %}
Sometimes it's necessary to adjust some of the metadata provided in the Patreon export, e.g. to list the user under another name on some "Thank yo" list than the one associated with the Patreon account. This can be done via a mapping file.
A mapping file is a YAML file that maps the email addresses of the affected Patrons to the overwritten metadata.
All of the Patron
object properties besides start_date
can be replaced this way. Only the fields present
in the mapping entry will be overwritten, all other fields will be left at the values taken from the
Patreon CSV export.
someone@example.com:
display_name: Some Company Name
someoneelse@example.com:
addressee: J. Random Patron
- Adapted to new columns in CSV export.
- Adapted to new columns in CSV export.
- Adapted to new format from the Relationship Manager, as the old Patron Manager is being retired by Patreon and with it the old CSV export.
- Level filtering for additionals
- Support for non integer pledge levels thanks to Patreon's STUPID new fee model.
- Now supports an additional mapping file to overwrite Patron metadata based on email address.
- Adapted to new CSV export format provided by Patreon
- Reward levels are now defined differently ("20.00+ Reward" => "20 + Reward")
- Street names might contain a "None" suffix if no additional address information (e.g. apt number) was supplied, stripping that, probably a Patreon export bug
- Detect changes in available columns & warn about it
- More resilience for change in available columns
- Adapted to new CSV export format provided by Patreon
- Added --until parameter
- Added address parsing
- Added --start parameter
- New dependencies: iso3166, python-dateutil
- Initial version
BSD