Skip to content

Instantly share code, notes, and snippets.

@sydney0zq
Created May 29, 2020 16:32
Show Gist options
  • Save sydney0zq/9727c53d28ba38ba60d5c4126ecf9705 to your computer and use it in GitHub Desktop.
Save sydney0zq/9727c53d28ba38ba60d5c4126ecf9705 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2020 qiang.zhou <qiang.zhou@Macbook>
#
# Distributed under terms of the MIT license.
"""
Calcuate the expenses on my own records.
"""
import sys
import os
TMP_FILE = "/tmp/payoff-temp.log"
cmd = "pbpaste > {}".format(TMP_FILE)
os.system(cmd)
with open(TMP_FILE, "r") as f:
data = f.read()
# Replace ',' to ',', remove blanks
data = data.replace(',', ',').replace(' ', '')
print ("Verbose the content in clipboard...")
print (data)
data_list = data.split('\n')
total_list = []
for item in data_list:
if ',' in item:
subpay = item.split(',')[-1]
else:
continue
subpay = float(subpay)
total_list.append(subpay)
total = sum(total_list)
print ("Total expend: {}".format(total))
print ("Max/Other: {}/{}".format(min(total_list), total-min(total_list)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment