inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

프로그래밍, 데이터 과학을 위한 파이썬 입문

Lab: Command Counter

command_data[]~ append(row)까지만 해서 실행했는데 다음과 같은 에러가 뜹니다.

339

루미꼬짱

작성한 질문수 1

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

python bigdata

답변 2

0

루미꼬짱

인코딩에러인듯하여, 검색을 통해 동일하게 변경해봤지만, 역시나 되지 않더라고요. 

다음과같은 에러가 발생합니다.

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\lib\codecs.py", line 322, in decode

    (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

파일을 읽어올 때 몇 개 글자가 읽어지지 않는 현상인거 같습니다. 

아래처럼 코드를 변경하실 수 있을세요?

with open("command_data.csv","r", encoding="utf8") as csvfile:

atom warning 글

0

337

0

backend.ai 설치 오류

0

315

0

backend.ai 설치 시 에러 발생

0

740

1

과제 제출 시 hash key is already used 문제 발생

0

445

0

install.bat 오류

0

478

0

과제 제출 시 hash key is already used. 해시키 문제 문의 드립니다.

0

308

1

"Hash key is already used."으로 인한 과제 제출 실패 문의

0

303

1

과제 제출 시 에러가 발생합니다

0

270

1

인트로 강의가 없습니다

0

180

0

사진 링크가 깨져있습니다

0

270

0

slack아직 사용할 수 있는건가요?

0

173

0

강의자료

0

398

4

'backend.ai'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다.

0

438

2

에러확인부탁드립니다.

0

258

1

number of cases 코드 질문

0

205

1

split 관련 질문입니다!

0

229

1

함수 definition 관련 질문입니다.

0

296

1

is_digit 함수 구현

0

306

1

Map & Reduce 강의 8분 15초

1

233

1

keyword parameter

0

239

1

submit.bat 오류

0

195

2

matrix_transpose 결과값이 뭐죠?

0

176

0

value를 넣으면 key를 반환하는 함수

0

129

0

첨부파일의 unit test는 어떻게 사용하나요?

0

267

0