open('master.csv') # 윈도우에서 기본: encoding='cp949'
open('master.csv') # 리눅스에서 기본: encoding='UTF-8' 윈도우에서는 인코딩을 지정해주어야 합니다
lines = open('master.csv').readlines()
# UnicodeDecodeError: 'cp949' codec can't decode byte 0xec in position 138: illegal multibyte sequence lines = open('master.csv', encoding='utf-8').readlines()
lines[:10] import chardet
contents = open('master.csv', 'rb').read()
chardet.detect(contents) contents = open('rss_30100041.xml', 'rb').read()
chardet.detect(contents) # 읽기
contents = open('master.csv', 'r', encoding='utf-8').read()
# 쓰기
open('master-euckr.csv', 'w', encoding='euc-kr').write(contents) contents = open('master-euckr.csv', 'rb').read()
det = chardet.detect(contents)
det import glob
for fn in glob.glob('*.csv'):
contents = open(fn, 'rb').read()
det = chardet.detect(contents)
print(f"{fn} ({det['encoding']})") import glob
for fn in glob.glob('*.csv'):
# detect encoding
contents = open(fn, 'rb').read()
det = chardet.detect(contents)
# convert encoding
if str(det['encoding']).lower() == 'utf-8':
text = open('master.csv', 'r', encoding='utf-8').read()
open(fn.replace('.csv', '_euckr.csv'), 'w', encoding='euc-kr').write(text) 윈도우 엑셀은 csv의 기본 인코딩을 cp949(EUC-KR)로 가정
C:\\>chcp 949 # 확장 EUC-KR
C:\\>chcp 65001 # 유니코드 8bit 출처 : https://financedata.notion.site/8c858b09203e4404a3b0d1de426dc078
코스피 8% 폭락, 서킷브레이커 발동, SK텔레콤 Claude AI 차단까지. 한국의 AI 레버리지 버블이 단 하루…
SNS 사진 1장으로 30초 만에 딥페이크 영상이 완성됩니다. 당신의 얼굴이 이미 범죄에 악용되고 있을 수…
SNS 사진 1장으로 30초 만에 딥페이크 영상이 완성됩니다. 당신의 얼굴이 이미 범죄에 악용되고 있을 수…
달러/원 환율이 급등하는 이유와 실생활 영향을 정리했습니다. 지금 당장 활용할 수 있는 환전·투자 대응 전략까지…
미래에셋·미래에셋벤처투자·미래에셋생명이 동반 급등한 이유는 스페이스X 상장 기대감입니다. 세 회사가 스페이스X와 어떻게 연결되어 있는지 상세히 분석했습니다.
스페이스X 상장이 계속 미뤄지는 진짜 이유를 파헤쳤습니다. 화성 계획, 스타링크 분리, 국방 계약... 머스크가 절대…