[Python] Read EBCDIC file in Python

Discussão em 'Python' iniciado por Stack, Novembro 19, 2024.

  1. Stack

    Stack Membro Participativo

    I've been trying to read a .ebc file but been unable to. I would like to save it as a .csv or txt file. (I'm new to this file format, so unsure on how to move forward)

    This is a description of the file, and the data is publicly available here (under Underground Injection Control Data)

    I've tried these threads but nothing has worked: Reading a mainframe EBCDIC File, How can I open .ebc (ebcdic) file on my laptop via python? Convert EBCDIC file to ASCII using Python 2

    1, does not print anything:

    import codecs

    with open("uif700a.txt", "rb") as ebcdic:
    ascii_txt = codecs.decode(ebcdic.read(), "cp500")
    print(ascii_txt)


    2, does not print anything

    with open("uif700.ebc", encoding='cp500') as f:
    print(f.read())


    3, file is also available as ASCII, so I tried:

    data = pd.read_csv('uif700a.txt', on_bad_lines='skip', encoding = "cp037",header=None)


    EmptyDataError: No columns to parse from file
    ​

    Continue reading...

Compartilhe esta Página