Reputation: 3
I'm trying to decode an EBCDIC file with the following Python code :
from os import path
import ebcdic
VERSION_EBCDIC = "cp1147"
def decodeEbcdic(inputDir, outputDir):
for root, subdirectories, files in walk(inputDir):
for subdirectory in subdirectories:
#do nothing
for file in files:
print(file)
f = open(path.join(root, file),'rb')
inputData = f.read()
f.close()
outputData = inputData.decode(VERSION_EBCDIC)
f = open(path.join(outputDir, file),'w')
f.write(outputData)
f.close()
decodeEbcdic(INPUT_DIR_EBCDIC, OUTPUT_DIR_ASCII)
I get the following error: UnicodeEncodeError: 'charmap' codec can't encode character '\x8e' in position 9: character maps to <undefined>
.
But, watching the input file with HxD I can't see the mentionned byte: hexadecimal description of the begginning of the input file
In fact, the byte 8E doesn't appear in the whole input file. nor does the byte E8.
But maybe I don't understand correctly the error message.
Upvotes: 0
Views: 78