Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
565 views
in Technique[技术] by (71.8m points)

mainframe - Access VSAM file using Python?

Is it possible to access VSAM datasets of mainframe using Python 3.8 in ZOS? I tried accessing vsam simple file in python 2.7 just like ps files. That seemed to be working. When i tried same in 3.8. It is not able to even read simple PS file data. Code:

import codecs                                      
f = open("//'VSAM file name'",'r')  
f1=codecs.getreader('cp1047_oe')(f)                
for line in f1:                                    
    print line,                                    
print (f1)                                         
print ("Read record is :", f)                      
f.close()   

                                   

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For trying to work with datasets there is a helpful blog entry that oulines the process: Using IBM Open Enterprise Python for z/OS and ZOAU to Work With Datasets

You will need to have the zoau binary along with having to install the zoautil_py python package. The instructions are available on their KC in the install section.

Note: There my be version changes from when the blog was published. I am using the zoau version V1.1.0 and there are some API call changes when compared to the blog, e.g. zoautil_py.Datasets is now zoautil_py.datasets. It would be preferable to use the latest stable version available.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...