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
Perhaps this reply is too late now (5 months later), but I'll give it a try. I had the same problem a couple of years ago with RRC EBC files. I had to reach out to an IBM friend to be able to solve the problem. This is what I did. Hope it help.
Note: this is not my entire code, so probably it is not going to run like it is.
YAML:
You need to do that to all field you are using (tedious). Note that if the value in the field doesn't take the entire length, the end will be filled with empty spaces
Python 3:
Now you have a list of values, but not decoded. They are all in binary.
Python 3:
Python 3:
Python 3: