강의

멘토링

로드맵

Inflearn Community Q&A

prushpark1623's profile image
prushpark1623

asked

Getting started with Python data analysis using public data

[3/20] Load data and preview, find out the number of rows and columns

read.csv 오류

Written on

·

377

1

working directory 설정방법을 몰라, 우선 다운로드받은 파일 경로를 아래와 같이 직접 입력하여 불러오기했는데 불러오기가 안됩니다.

pandaspythonnumpy

Answer 1

1

todaycode님의 프로필 이미지
todaycode
Instructor

안녕하세요.

경로를 직접 적어주셨는데 구문오류가 발생하고 있어요.

이 때 경로에 들어가는 특수문자 때문에 인코딩 오류가 발생하는 것으로 보여져요.

경로 앞에 r 이라는 문자를 적어주세요 r"C:\User..경로" 이렇게요!

r 은 raw를 의미해요. 아래 스택오버플로우의 답변을 참고해 보세요!

https://stackoverflow.com/questions/2953834/windows-path-in-python

you can use always: 아래와 같이 역슬래시를 슬래시로 바꿔주셔도 됩니다.

'C:/mydir'

this works both in linux and windows. Other posibility is 아니면 역슬래시 앞에 슬래시를 하나 더 해서 예외처리를 해줍니다.

'C:\\mydir'

if you have problems with some names you can also try raw string literals: 간단한 방법으로 r을 쓰면 raw 문자로 경로를 읽어옵니다.

r'C:\mydir'

prushpark1623's profile image
prushpark1623

asked

Ask a question