Skip to content Skip to sidebar Skip to footer

How Do I Use Output From SPARC Solver As Input To A Python File?

My question: I need to save the output from a SPARC solver (which is currently appearing as text in the terminal) as a variable in my Python code. How can I do this? Quick note: SP

Solution 1:

You can use python to read from sys.stdin with a script similar to the following (filter.py):

import sys
for line in sys.stdin.readlines():
  if line.startswith('?- '):
    print line.strip()

Then invoke your pipeline like this:

python pythonfile.py | java -jar sparc.jar aspfile.sp | python filter.py

Solution 2:

I would suggest you do dump SPARK output to text file and then to parse it with you tool.

Write a shell script that does it for you:

python pythonfile.py | java -jar sparc.jar aspfile.sp > spark.out
python parse_out.py spark.out

Post a Comment for "How Do I Use Output From SPARC Solver As Input To A Python File?"