Created
February 18, 2016 13:22
-
-
Save jeffbaumes/2a8df131b158b0b6c0a1 to your computer and use it in GitHub Desktop.
Romanesco conversion utility
This file contains 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
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