File size: 417 Bytes
a785ccd
 
 
 
 
 
 
1
2
3
4
5
6
7
8
import csv
w = csv.writer(open("accounts.csv", "w", newline="")); w.writerow(["account", "name", "balance", "opened"])
for line in open("listing.txt"):
    if not line[:8].strip().isdigit(): continue
    b = line[30:42].strip(); neg = b.endswith("-"); b = float(b.rstrip("-").replace(",", ""))
    d = line[42:50]
    w.writerow([line[:8], line[8:30].strip(), f"{-b if neg else b:.2f}", f"{d[:4]}-{d[4:6]}-{d[6:]}"])