본문 바로가기

명사 美 비격식 (무리 중에서) 아주 뛰어난[눈에 띄는] 사람[것]

PYTHON

csv는 encoding='cp949'로 인코딩해보기! : UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbf in position 0: invalid start byte

encoding 에러가났다. 

---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
/tmp/ipykernel_28479/3951916220.py in <cell line: 0>()
      1 file_path = '/content/drive/MyDrive/data/sample2.csv'
      2 with open(file_path, 'r') as f:
----> 3     print(f.read())

/usr/lib/python3.12/codecs.py in decode(self, input, final)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbf in position 0: invalid start byte

 

 

cp949 인코딩 추가.

file_path = '/content/drive/MyDrive/data/sample2.csv'
with open(file_path, 'r', encoding='cp949') as f:
    print(f.read())