Skip to content

Commit 924864f

Browse files
authored
Update catalog.py
fixed error 'TypeError: a bytes-like object is required, not 'str'' when read_ldac function is invoked for reading .ldac files
1 parent ec067a6 commit 924864f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

catalog.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,12 @@ def read_ldac(self, filename, fits_filename=None, maxflag=None,
766766
# set other properties
767767
telescope = ''
768768
for line in hdulist[1].data[0][0]:
769-
if telescope_keyword in line:
770-
telescope = line.split('\'')[1]
769+
if isinstance(line, bytes):
770+
line_str = line.decode('utf-8') # Decode bytes to string
771+
else:
772+
line_str = line # Already a string
773+
if telescope_keyword in line_str:
774+
telescope = line_str.split('\'')[1]
771775
self.catalogname = filename
772776
if fits_filename is not None:
773777
self.origin = '{:s};{:s}'.format(telescope.strip(), fits_filename)

0 commit comments

Comments
 (0)