Mercurial > hg > freeDiameter
view contrib/tools/org_to_csv @ 1469:48fa8d70e6ad
csv_to_fd: validate flags and other improvements
Validate the flags.
Allow more columns; ignore any past column 8 "Must Not".
Add basename of filenames to the regen command.
author | Luke Mewburn <luke@mewburn.net> |
---|---|
date | Wed, 18 Mar 2020 11:40:01 +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 :