Working with Google Sheets
LakeOps provides seamless integration with Google Sheets, allowing you to read and write data directly between your data lake and spreadsheets.
Quick Start
from lakeops.core.engines import GoogleSheetsEngine
from lakeops.core.secrets import DatabricksSecretManager
secrets = DatabricksSecretManager()
credentials = secrets.read("google_credentials", scope="production")
lake = GoogleSheetsEngine(credentials)
Authentication
LakeOps uses Google Service Account for authentication with Google Sheets API. Here's how to set it up:
-
Create Service Account:
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google Sheets API for your project
- Go to "IAM & Admin" > "Service Accounts"
- Click "Create Service Account"
- Download the JSON key file
-
Store Service Account in LakeOps Secrets:
secrets.write("google_credentials", "<SECRETS FILE CONTENT>", scope="production")
Features
Reading data
# Read from Google Sheet
df = lake.read(
"1234567890abcdef", <-- Google Sheet ID
format="gsheet",
)
Writing data
import polars as pl
# Write to Google Sheet
sales_data = pl.DataFrame({
"date": ["2024-01-01", "2024-01-02"],
"revenue": [1000, 1200]
})
lake.write(
sales_data,
"1234567890abcdef", <-- Google Sheet ID
format="gsheet",
)
Best Practices
- Use service accounts for production workloads
- Use batch operations for large datasets