Skip to content

Instantly share code, notes, and snippets.

@jch
Created December 29, 2016 17:38
Show Gist options
  • Save jch/fe6155f9bd01564f18cf398e225edcd9 to your computer and use it in GitHub Desktop.
Save jch/fe6155f9bd01564f18cf398e225edcd9 to your computer and use it in GitHub Desktop.
# Clean up Mint exported transactions for working with a spreadsheet
#
# Usage:
#
# ruby mint.rb <transactions.csv>
#
# Export a CSV of transactions from Mint
#
# Tags are not exported, so it must be filtered out before export:
#
# https://mint.intuit.com/transaction.event?#location:{"query":"-tag:Reimbursable, -tag:Tax Withholding"}
#
require 'csv'
require 'date'
csv = CSV.new(ARGF.read, headers: :first_row, converters: [:numeric], return_headers: true)
csv.each do |row|
# print out headers
puts row and next if row['Date'] == 'Date'
next unless row['Date'] =~ /2016/ # date converter not working
next if ['Transfer', 'Paycheck', 'Credit Card Payment', 'Income', 'Interest Income'].include?(row['Category'])
row['Amount'] = -row['Amount'] if row['Transaction Type'] == 'debit'
puts row
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment