Skip to content

Instantly share code, notes, and snippets.

@lapo-luchini
Created July 1, 2023 11:29
Show Gist options
  • Save lapo-luchini/b2e40b2d468ddf631ddd9b137996fe69 to your computer and use it in GitHub Desktop.
Save lapo-luchini/b2e40b2d468ddf631ddd9b137996fe69 to your computer and use it in GitHub Desktop.
Convert SatisPay CSV export to QIF format
#!/bin/sh
export LANG=C
cat Satispay-*.csv | \
gawk -F ' *, *' '
NR>1 {
match(substr($5, 2), "^([0-9]{1,2}) ([a-z]{3}) ([0-9]{4})$", a)
switch (a[2]) {
case /gen|jan/: a[2] = "01"; break;
case "feb": a[2] = "02"; break;
case "mar": a[2] = "03"; break;
case "apr": a[2] = "04"; break;
case /mag|may/: a[2] = "05"; break;
case /giu|jun/: a[2] = "06"; break;
case /lug|jul/: a[2] = "07"; break;
case /ago|aug/: a[2] = "08"; break;
case /set|sep/: a[2] = "09"; break;
case /ott|oct/: a[2] = "10"; break;
case "nov": a[2] = "11"; break;
case /dic|dec/: a[2] = "12"; break;
default: print "Error in: " $0 > "/dev/stderr"; exit 1;
}
date = a[1] "/" a[2] "/" a[3]
note = "[" $2 "]"
if ($9) note = $9 " " note
print "D" date
print "P" $2
print "M" note
print "T" $7
print "^" $8
}
' >Satispay-fix.qif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment