gspread API 연동
gspread API 연동 위해 GCP 계정, 서비스 계정 다시 팜.
기존 계정 날아감 (클라우드 콘솔 오래 안써서 삭제됨).
GCP에서 새 프로젝트 생성.
Google Sheets API enable.
Service account 발급.
Service account 들어가서 key 추가, JSON 파일로 받음.
Google Sheet에 서비스 계정 이메일 공유.
[서비스 계정 이메일] (예: urustin@haranggotgam.iam.gserviceaccount.com)
파이썬에서 gspread 사용:
import gspread
gc = gspread.service_account(filename='[json 파일 경로]')
sh = gc.open('[스프레드시트 이름]')
# 워크시트 선택
worksheet = sh.get_worksheet([인덱스]) # 0부터 시작
# 또는
worksheet = sh.worksheet('[시트 이름]')
gc.open('[스프레드시트 이름]'): 스프레드시트 이름으로 열기.sh.get_worksheet([인덱스]): 인덱스로 워크시트 선택.sh.worksheet('[시트 이름]'): 이름으로 워크시트 선택.
여기서 배울 것
- GCP에서 새 프로젝트 파는 것부터 시작.
- Google Sheets API는 따로 enable 해야 함.
- Service account 만들고 JSON 키 받아야 함.
- 스프레드시트에 서비스 계정 이메일 공유 필수.
원본 파일 보기 (.claude/skills/tn-gspread-api-setup/SKILL.md)
---
name: gspread API 연동 설정
description: This skill should be used when the user asks to set up `gspread` for programmatic access to Google Sheets, including creating a Google Cloud Platform service account, enabling the Google Sheets API, and generating API keys for authentication.
version: 1.0.0
source: /home/son/prj/resume/backup_notes_260317/notion/Tech Note/gspread API fa15bdd395364395a9e1ba8d55534a4d.md
---
# gspread API
기존 계정이 날아감 (클라우드 콘솔 오래 안써서 삭제됨)


gcp에서 새로 생성

api enable

service account 발급


service account 들어가서 add key하면 json으로 받을 수 있음.
share authority
**urustin@haranggotgam.iam.gserviceaccount.com**
(previously activate google sheets api / get key and iam account)
select sheet :
.get_worksheet(index) / worksheet(’string’)
