Skip to content
Prev Previous commit
Next Next commit
Read .gr file, convert to utf-8:
  • Loading branch information
bobleesj committed Oct 23, 2024
commit f2b65ad9cc4a492be52bc9571f6370a718c8b586
5 changes: 4 additions & 1 deletion src/diffpy/srmise/pdfdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ def read(self, filename):
self
"""
try:
self.readStr(open(filename, "rb").read())
# Open the file in binary mode, read it, and decode to convert bytes to string
with open(filename, "rb") as file:
file_content = file.read().decode('utf-8')
self.readStr(file_content)
except PDFDataFormatError as err:
basename = os.path.basename(filename)
emsg = ("Could not open '%s' due to unsupported file format " + "or corrupted data. [%s]") % (
Expand Down