-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
미해결
command_data[]~ append(row)까지만 해서 실행했는데 다음과 같은 에러가 뜹니다.
19.09.03 16:19 작성 조회수 176
0
[코드]
import csv
def aetKev(item): # 데이터 정렬코드
return item[1]
command_data=[] # 파일 읽어오기 코
with open("command_data.csv","r") as csvfile:
spamreader=csv.reader(csvfile, delimiter=',', quotechar='"')
for row in spamreader:
command_data.append(row)
print(len(command_data))
[실행에러]
C:\workspace>python dict.py
Traceback (most recent call last):
File "dict.py", line 8, in <module>
for row in spamreader:
UnicodeDecodeError: 'cp949' codec can't decode byte 0x80 in position 590: illegal multibyte sequence
답변을 작성해보세요.
0
루미꼬짱
질문자2019.09.11
인코딩에러인듯하여, 검색을 통해 동일하게 변경해봤지만, 역시나 되지 않더라고요.
다음과같은 에러가 발생합니다.
C:\workspace>python dict.py
Traceback (most recent call last):
File "dict.py", line 9, in <module>
for row in spamreader:
File "C:\Users\ohmija\Miniconda3\
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1775-1776: invalid continuation byte
여기서 막혀서, 다음강좌를 넘어가기가 어렵네요.
보통 pandas 라이브러리를 import해서 csv파일 불러올때, 변수명=csv.read(파일명)정도로만 하던데, 이런 형태로 코딩하는 것은 row별로 불러오려고 해서 그런걸까요?
0
TeamLab
지식공유자2019.09.07
파일을 읽어올 때 몇 개 글자가 읽어지지 않는 현상인거 같습니다.
아래처럼 코드를 변경하실 수 있을세요?
with open("command_data.csv","r", encoding="utf8") as csvfile:
답변 2