Python

  • 1.  reading an MVS dataset using Z Open Automation Utility

    Posted Fri November 11, 2022 09:11 AM
    I have installed IBM Python Open Enterprise Python for z/OS along with ZOAU 1.2.1. I want to read an MVS data line by line, basically use readlines() method on the MVS dataset. But the only method I find available in ZOAU with MVS datasets is read, which reads the entire file in one go as a byte stream. I want to iterate over the individual records in the MVS dataset rather than reading the whole dataset.
    I know the work around is to copy the MVS dataset to a zFS file, which then will let me use the readlines() method on the file. But can I do it without copying the MVS dataset to a zFS file?

    Thank you
    Nagaraj

    ------------------------------
    NAGARAJ SESHAGIRI PUDUKOTAI
    ------------------------------


  • 2.  RE: reading an MVS dataset using Z Open Automation Utility

    Posted Fri November 11, 2022 04:52 PM
    Hi. ZOAU Does not currently support reading datasets line by line. If you are okay with reading the entire dataset, you can still iterate over over it in the same manner by doing the following:

    all_lines = zoautil_py.datasets.read(...).split("\n")​
    for line in all_lines:
       # do work here


    Regards,

    Steven Pitman



    ------------------------------
    Steven Pitman
    ------------------------------



  • 3.  RE: reading an MVS dataset using Z Open Automation Utility

    Posted Mon November 14, 2022 12:59 AM
    Thank you Steven.  I am running out of memory when I issue a read on the dataset, because it is huge. It has more than 2 million records in it. Hence I am looking for a way around it and I thought it might help if I read and iterate over one line at a time, instead of reading all of it and then iterate over each record.

    ------------------------------
    NAGARAJ SESHAGIRI PUDUKOTAI
    ------------------------------



  • 4.  RE: reading an MVS dataset using Z Open Automation Utility
    Best Answer

    Posted Mon November 14, 2022 05:30 AM





  • 5.  RE: reading an MVS dataset using Z Open Automation Utility

    Posted Mon November 14, 2022 06:13 AM
    Thank you Colin. It looks very promising to try out. I have a question for you about how to go about installing this package in the zOS environment. The zOS LPAR is not connected to the internet. So will it work if I download the github repo of pyzfile as a ZIP archive, upload it to the LPAR, unzip it there and then do a pip install of the unzipped file?

    ------------------------------
    NAGARAJ SESHAGIRI PUDUKOTAI
    ------------------------------



  • 6.  RE: reading an MVS dataset using Z Open Automation Utility

    Posted Mon November 14, 2022 07:07 AM
    Hi Colin
    I managed to install it by downloading the zip file, uploading it to the zOS LPAR, unzipping it and then running the pip program against the pyzfile-1.0.0.post2-py3-none-any.whl in the pyzfile/dist folder.  I test it and it worked great. 

    Thank you very much for pointing me in the direction.

    Nagaraj

    ------------------------------
    NAGARAJ SESHAGIRI PUDUKOTAI
    ------------------------------