Last active
November 6, 2024 15:26
-
-
Save mkhon/7b6eee106f5e51767464124d806b2fd6 to your computer and use it in GitHub Desktop.
Convert 1C export to CSV
This file contains hidden or 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/env python | |
import sys, csv | |
m = __import__('1c_format') | |
data = m.parse(sys.argv[1]) | |
rows = data['СекцияДокумент'] | |
all_keys = set() | |
for d in rows: | |
for k in ['Банковский ордер', 'Платежное поручение']: | |
if k in d: | |
d['Тип документа'] = k | |
del d[k] | |
all_keys.update(d.keys()) | |
w = csv.DictWriter(sys.stdout, fieldnames=list(all_keys)) | |
w.writeheader() | |
w.writerows(rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment