Mercurial > hg > freeDiameter
view contrib/tools/org_to_csv @ 1487:5c2d061a8c8e
csv_to_fd: improve validation
When an AVP Code or Name is duplicate, differentiate
between a duplicate entry (AVPs are equivalent)
versus an actual mismatch.
Consistent AVP formatting in errors.
Collect all errors and display at end of each file parse,
instead of exiting on first error.
author | Luke Mewburn <luke@mewburn.net> |
---|---|
date | Fri, 27 Mar 2020 15:32:27 +1100 |
parents | a86eb3375b95 |
children |
line wrap: on
line source
#!/usr/bin/env python """ Convert |-separated 11-column .org files to CSV, with first and last empty columns ignored. """ import csv import fileinput import re import sys csvout = csv.writer(sys.stdout) for line in fileinput.input(): row = re.split(r'\s*\|\s*', line) row.extend([''] * (10 - len(row))) csvout.writerow(row[1:10]) # vim: set et sw=4 sts=4 :