Skip to content

Text files not reading in under AMCReader with Python 3 #28

@amcody

Description

@amcody

The way that Python 3 reads in text files is different from Python 2, which means that the header column names get turned into bytes instead of strings, which means that the header check fails. The way I'm writing the ascii files, there is no encoding option. So the way I got this to work again was to change the third line here:

k2sc/src/k2io.py

Lines 82 to 86 in 33eedb9

def can_read(cls, fname):
ext_ok = cls.is_extension_valid(fname)
with open(fname, 'rb') as f:
header = f.readline().lower().split()
head_ok = all([cn in header for cn in 'dates cadences xpos ypos quality'.split()])

to
with open(fname, 'r', encoding='utf-8') as f:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions