Skip to content

Instantly share code, notes, and snippets.

@jeffbaumes
Created February 18, 2016 13:22
Show Gist options
  • Save jeffbaumes/2a8df131b158b0b6c0a1 to your computer and use it in GitHub Desktop.
Save jeffbaumes/2a8df131b158b0b6c0a1 to your computer and use it in GitHub Desktop.
Romanesco conversion utility
import sys
import romanesco
if __name__ == '__main__':
if len(sys.argv) != 6:
print """Usage:
python convert.py input_file type input_format output_format output_file
Example:
python convert.py hi.csv table csv rows.json hi.rows-json
"""
exit(1)
input = sys.argv[1]
type = sys.argv[2]
in_format = sys.argv[3]
out_format = sys.argv[4]
output = sys.argv[5]
with open(input) as input_file:
input_data = input_file.read()
out = romanesco.convert(type, {'format': in_format, 'data': input_data}, {'format': out_format})
with open(output, 'w') as output_file:
output_file.write(out['data'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment