Skip to content

Instantly share code, notes, and snippets.

@tcoliver
Created May 28, 2020 15:33
Show Gist options
  • Select an option

  • Save tcoliver/7e41f595d331ff0851e79f5f9c32c587 to your computer and use it in GitHub Desktop.

Select an option

Save tcoliver/7e41f595d331ff0851e79f5f9c32c587 to your computer and use it in GitHub Desktop.
Simple script for converting a transaction CSV exported from USAA into a YNAB import compatible format.
import argparse
import csv
import pathlib
parser = argparse.ArgumentParser()
parser.add_argument("infile", type=str, help="CSV file exported from USAA's web portal")
parser.add_argument(
"outfile",
nargs="?",
type=str,
help="CSV file to create. (default: 'ynab_out.csv' within infile's parent directory)",
)
args = parser.parse_args()
if args.outfile is None:
args.outfile = pathlib.Path(args.infile).parent / "ynab_out.csv"
with open(args.infile, "r", newline="") as infile, open(args.outfile, "w", newline="") as outfile:
ussa_reader = csv.DictReader(
infile,
fieldnames=["Status", "Blank1", "Date", "Blank2", "Payee", "Memo", "Amount"],
)
ynab_writer = csv.DictWriter(
outfile,
fieldnames=["Date", "Payee", "Memo", "Amount"],
extrasaction="ignore"
)
ynab_writer.writeheader()
ynab_writer.writerows(ussa_reader)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment