Created
July 25, 2022 01:58
-
-
Save bigntallmike/a735938c8b8d7a03813f65da0214a170 to your computer and use it in GitHub Desktop.
This file contains 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/python3 -ttu | |
# Quick massage of cut'n'paste data from Royal Bank of Canada statement data: | |
import string | |
import sys | |
Months = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") | |
tabcount = 0 | |
for data in sys.stdin: | |
data = data.rstrip("\r\n \t") | |
if data[:3] in Months: | |
tabcount = 0 | |
sys.stdout.write("\n%s" % data) | |
else: | |
tabcount += 1 | |
if data[:1] == "-" and tabcount < 3: | |
# Negative values should be in column 4 (3 tabs) | |
sys.stdout.write("".join("\t" for _ in range(3 - tabcount))) | |
elif data[:1] == "$" and tabcount < 4: | |
# Positive values should be in column 5 (4 tabs) | |
sys.stdout.write("".join("\t" for _ in range(4 - tabcount))) | |
sys.stdout.write("\t%s" % data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment