Created
September 3, 2021 18:52
-
-
Save varenc/d2b52e238d56df9ebf93112160985bb2 to your computer and use it in GitHub Desktop.
Plaid CCPA data export to JSON converter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
### Converts your Plaid CCPA data export to JSON | |
# | |
# Plaid's CCPA export of your personal data comes in a bespoke unparseable format. It's almost | |
# a literal Python object but not quite. This script converts that data to JSON. | |
# To make a CCPA request go here: https://plaid.com/legal/data-protection-request-form/ | |
# (You might not even have to be a California resident) | |
# | |
# Once you have the data, just call this script and provide one of the files as an argument: | |
# $ python3 plaid_ccpa_request_dump_data.py INPUT_FILE > plaid_data.json | |
# | |
import json | |
import sys | |
def main(): | |
if len(sys.argv) <= 1: | |
print(""" | |
You must provide an argument pointing to a file in your Plaid CCPA export. | |
Like this: | |
$ python3 plaid_ccpa_request_dump_data.py bofa_report2021-0901-1127_23ac21 | |
""") | |
return | |
report=get_plaid_data(sys.argv[1]) | |
print(json.dumps(report,indent=4)) | |
def get_plaid_data(fname): | |
# To make Plaid's export valid Python, prepend an opening bracket and remove another extra bracket. This is very brittle. | |
pyvar="{" + "".join(open(fname,'r').readlines()).replace('1}},','1},') | |
# Since Plaid's export is quite literally a Python object, we just evaluate it. (eval=evil... one letter difference. Coincidence??) | |
exec("report="+pyvar, globals()) | |
return report | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment