Jacob Kaplan-Moss

Tag: google spreadsheets

TIL: A DictWriter interface for Google Spreadsheets August 21st, 2023

I’ve been using Python’s csv library approximately forever so its interfaces – particularly the DictReader and DictWriter interfaces – are almost literally muscle memory at this point. So when I needed to push a bunch of data to Google Sheets, I naturally wanted an interface that worked like DictWriter. Here’s the code: class WorksheetDictWriter: """ Something like a `csv.DictWriter`, except for a `gspread.Worksheet` """ def __init__(self, worksheet: gspread.Worksheet, fieldnames: list[str], column="A"): self.…