[GNC] CSV to QIF for Citibank
Michael DeBusk
mdebusk at gmail.com
Mon Jun 17 01:13:06 EDT 2019
Some time back, Citibank decided it would stop offering its transactions in
QIF format. I edited the CSV in vim (I only had a few transactions) until
this past week, when I realized I can't be a good Linux nerd unless I
automate repetitive tasks.
This is my attempt at an awk script specific to Citibank's file format. The
QIF needs some editing after it's done, but it'll save me a lot of time
until they change the format again.
(I'd appreciate criticism from awk masters on the list.)
#!/usr/bin/awk -f
BEGIN {
FS=","
print "!Account"
print "NLiabilities:Citibank:Costco Anywhere Visa" # Change to your
account
print "TCCard"
print "\\Statement Balance Date"
print "$Statement Balance"
print "^"
print "!Type:CCard"
}
FNR == 1 { next }
{
print "D"$2
if ($3~/AUTOPAY/) {
print "PCitibank";
print "T"sqrt($5^2); # This gets rid of the "-" before the amount
print "LAssets:Current Assets:"; # change to your checking account
print "MAutopay";
}
else {
print "P"tolower(substr($3, 2, length($3)-2)); # This gets rid of
the double quotes around this string, and lower-case it
print "T-"$4;
print "LExpenses:&&";
print "M&&";
}
print "^"
}
--
Home: http://nlphilia.com * Blog: http://nlphilia.net
Registered Linux User #450983 * Ubuntu Counter Project #10548
More information about the gnucash-user
mailing list