# adapted from answer of Stack Overflow user in the source link # file is open read only f = open('path/to/file', mode = 'r', encoding='utf-8-sig')