0

I'm not sure if I'm titling my question correctly, but I have the following situation:

I am subprocessing a Scala script which ingests a json file, and the output is a string in json format. Right now I have the following code:

with open("stdout.txt", "w") as out: p = subprocess.Popen(['sbt', '--error', 'run /jsonfolder/Example.json'], cwd = BASEDIR, stdout = out) print out

which writes the stdout.txt file in my directory containing the outputted string in json format. However, I'd like to "transform" this .txt file into a .json where it is "pretty" and "structured."

I've tried with open("stdout.json", "w") as out: instead, but it did not work.

boldbrandywine
  • 322
  • 1
  • 14
  • 1
    to clarify, the output is correct but just not in the format you want? this post might help if you haven't seen it: http://stackoverflow.com/questions/12943819/how-to-python-prettyprint-a-json-file – mitoRibo Aug 24 '16 at 00:25
  • Yep! That did the trick! Thanks much. – boldbrandywine Aug 24 '16 at 02:09

0 Answers0