Skip to content

Instantly share code, notes, and snippets.

@CRImier
Created April 10, 2018 21:19
Show Gist options
  • Select an option

  • Save CRImier/ad8c27c19dea801c34bf26cd8820c433 to your computer and use it in GitHub Desktop.

Select an option

Save CRImier/ad8c27c19dea801c34bf26cd8820c433 to your computer and use it in GitHub Desktop.
Swedbank Latvia CSV parser script, creates a nice dictionary
import csv
f = open("statement.csv", "r", encoding="iso8859_13")
#def reencode(file):
# for line in file:
# yield line.decode('iso8859_13').encode('utf-8')
r = csv.reader(f, delimiter=";", quotechar='"')
l = [line for line in r]
names = ["account", "num1", "date", "sender", "desc", "amount", "currency", "k-d", "date_precise", "type", None, "document_num"]
donations = []
for line in l:
d = {}
for i, name in enumerate(names):
if name:
d[name] = line[i]
donations.append(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment