Hi Garry,
AFAIK, there's no way to open data sets using IBM's Python built-in functions.
You can use the functions zoautil_py.datasets.read() and zoautil_py.datasets.write() from ZOAUtil.
More examples can be found in this blog (recommended in IBM's doc for Python).
Another workaround would be to use the subprocess module to pipe the data set contents through a shell command, e.g. cat
.
See example #1 and example #2 below:
example 1
import subprocess
print(subprocess.run(["cat", "//'DATA.SET.NAME'"], capture_output = True, encoding = "iso8859-1").stdout)
example 2
import subprocess
with subprocess.Popen("cat \"//'DATA.SET.NAME'\"", shell=True, stdout=subprocess.PIPE, encoding = "iso8859-1").stdout as pipe:
print(pipe.readlines())
Note that the encoding is deliberately specified as ISO8859-1 because cat
will automatically convert data set contents to this encoding.
Thanks,
Alexander