jm_p_op

스프레드시트에서 python으로 데이터 불러오기 본문

py/자동화

스프레드시트에서 python으로 데이터 불러오기

jm_p_op 2024. 1. 29. 17:27

https://console.cloud.google.com/apis/dashboard?project

 

Google 클라우드 플랫폼

로그인 Google 클라우드 플랫폼으로 이동

accounts.google.com

프로젝트 생성

생성 후,

이메일 클릭

키만들고 저장.


import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = [
'https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive',
]
json_file_name = '저장한 파일명'
credentials = ServiceAccountCredentials.from_json_keyfile_name(json_file_name, scope)
gc = gspread.authorize(credentials)
spreadsheet_url = '스프레드시트 url'
doc = gc.open_by_url(spreadsheet_url)

그중 필요 데이터 뽑기

https://greeksharifa.github.io/references/2023/04/10/gspread-usage/#gspread-%EC%82%AC%EC%9A%A9%EB%B2%95

 

Python, Machine & Deep Learning

Python, Machine Learning & Deep Learning

greeksharifa.github.io

 


데이터를 가져올때 필요한것만 최대한 한번에 가지고 와야지 API 코스트가 적다.

함수를 잘짜서 가지고 오자!

'py > 자동화' 카테고리의 다른 글

python - hwp 특정 위치 수정  (0) 2024.02.04
python hwp 파일 열고 쓰기  (0) 2024.02.04