How to execute fastavro shell command on in only python code?

37 Views Asked by At

I have a working AVRO converter that will output JSON formatted schema & records files and a CSV records file. To generate the JSON schema & recodes files I'm calling the following fastavro shell commands.

Schema:

subprocess.run("fastavro --schema -p" + avro_file + ">" + schout_file, shell=True, check=True)

Records:

subprocess.run("fastavro -p" + avro_file + ">" + rcdout_file, shell=True, check=True)

I really don't like calling a shell command from within my Python code, but this was the only way I have gotten this to work. Can someone show me how to replicate these fastavro commands only in Python-3. (I've looked everywhere in the docs and other sites but don't see the functionality of these commands written out as only Python code)

0

There are 0 best solutions below