Mercurial > hg > freeDiameter
comparison contrib/tools/org_to_csv @ 1461:a86eb3375b95
add csv_to_fd, org_to_csv tools
csv_to_fd converts CSV files containing RADIUS or Diameter AVP tables
into various formats, including freeDiameter C code and JSON documents.
org_to_csv converts org files into CSV files, suitable for csv_to_fd.
author | Luke Mewburn <luke@mewburn.net> |
---|---|
date | Mon, 09 Mar 2020 21:24:24 +1100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1460:4f44d206e60d | 1461:a86eb3375b95 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 """ | |
4 Convert |-separated 11-column .org files to CSV, | |
5 with first and last empty columns ignored. | |
6 """ | |
7 | |
8 import csv | |
9 import fileinput | |
10 import re | |
11 import sys | |
12 | |
13 csvout = csv.writer(sys.stdout) | |
14 for line in fileinput.input(): | |
15 row = re.split(r'\s*\|\s*', line) | |
16 row.extend([''] * (10 - len(row))) | |
17 csvout.writerow(row[1:10]) | |
18 | |
19 # vim: set et sw=4 sts=4 : |