z/OS Tools & Language

Expand all | Collapse all

Are there any code samples available?

  • 1.  Are there any code samples available?

    Posted 10-25-2016 16:44

    I am looking for code samples of how to work with MVS datasets and members and other z/OS specific tasks that have been already accomplished with Python.

    Thanks



  • 2.  RE: Are there any code samples available?

    Posted 10-27-2016 10:39

    Hi, Miehner.

    I hope it will help: https://pypi.python.org/pypi/PyZOS
    It’s Z/OS-API.

    Regards,
    Andrey



  • 3.  RE: Are there any code samples available?

    Posted 01-06-2017 10:12

    With 2.7.12 Beta2 from Nov 2016 the following script reads a member in a PDS and prints it.

    Different to the earlier 2.7.6 release internal Python strings are in ASCII/Latin1 encoding so conversion needs to be done.

    It will be interesting to see if in a future release some automatic conversion will be done for text files, especially if they have encoding tags set on the file system.

    import codecs                                                         
    with open('//MM.JCL(TEST)','r') as f:          # open file in text/record mode
        stream = codecs.getreader('cp1047_oe')(f)  # convert data from EBCDIC to Latin1                       
        for line in stream:                                               
            print line[:-1]  # print line w/o last character (=new line)  
    

    Please see also the discussion in Python sample code files