We're having an issue trying to read a z/OS dataset. It works for a USS file. Running Python 3.95 in the base environment.
What are we missing?
thanks
# FileNotFoundError: [Errno 129] EDC5129I No such file or directory.
with open("//'xxxxxx.x.xxxxx'", 'r') as f:
print(f.read())
# this works
with open('/u/xxxxxx/python/aws.py', 'r') as f:
print(f.read())
We're having an issue trying to read a z/OS dataset. It works for a USS file. Running Python 3.95 in the base environment.
What are we missing?
thanks
# FileNotFoundError: [Errno 129] EDC5129I No such file or directory.
with open("//'xxxxxx.x.xxxxx'", 'r') as f:
print(f.read())
# this works
with open('/u/xxxxxx/python/aws.py', 'r') as f:
print(f.read())
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 1import subprocessprint(subprocess.run(["cat", "//'DATA.SET.NAME'"], capture_output = True, encoding = "iso8859-1").stdout)
example 2import subprocesswith 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
We're having an issue trying to read a z/OS dataset. It works for a USS file. Running Python 3.95 in the base environment.
What are we missing?
thanks
# FileNotFoundError: [Errno 129] EDC5129I No such file or directory.
with open("//'xxxxxx.x.xxxxx'", 'r') as f:
print(f.read())
# this works
with open('/u/xxxxxx/python/aws.py', 'r') as f:
print(f.read())
Thanks for the update regarding IBM's ZOAU and also the examples.
Is this a feasible way using cat as well? Any limitations?
import os
os.system("cat ""//'xxx.xxx(xxx)'""")
os.system("cat ""//'xxx.xxx'""")
Thanks,
Gary
We're having an issue trying to read a z/OS dataset. It works for a USS file. Running Python 3.95 in the base environment.
What are we missing?
thanks
# FileNotFoundError: [Errno 129] EDC5129I No such file or directory.
with open("//'xxxxxx.x.xxxxx'", 'r') as f:
print(f.read())
# this works
with open('/u/xxxxxx/python/aws.py', 'r') as f:
print(f.read())
Hi Garry,
According to os.system documentation it just executes the command, it doesn't capture the output and the return value is the exit status of the process.
Thanks,
Alexander
Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.