Downloading text files with Python and ftplib.FTP from z/os

后端 未结 4 943
無奈伤痛
無奈伤痛 2021-01-05 18:31

I\'m trying to automate downloading of some text files from a z/os PDS, using Python and ftplib.

Since the host files are EBCDIC, I can\'t simply use FTP.retrbinary(

4条回答
  •  旧时难觅i
    2021-01-05 19:08

    Use retrlines of ftplib to download file from z/os, each line has no '\n'.

    It's different from windows ftp command 'get xxx'.

    We can rewrite the function 'retrlines' to 'retrlines_zos' in ftplib.py.

    Just copy the whole code of retrlines, and chane the 'callback' line to:

    ...

    callback(line + "\n")

    ...

    I tested and it worked.

提交回复
热议问题