gspread
Google Sheets Python API
A Python library that lets you read and write Google Sheets from code, open a spreadsheet, update cells, and automate data entry without ever touching a browser.
gspread is a Python library that lets you read and write Google Sheets from code. Instead of opening a spreadsheet in a browser and editing it by hand, you write a Python script that connects to Google Sheets, opens a specific file, and reads or updates cells programmatically. This is useful for automating data entry, pulling spreadsheet data into a script, or updating a sheet based on calculations your code performs.
The library works with Google's Sheets API and requires setting up credentials in Google's API Console first. Once credentials are configured, you authenticate once and then open spreadsheets by title, key, or URL. From there you can read individual cells, entire rows or columns, or ranges of cells. You can also write data back, format cells, create or delete worksheets, share spreadsheets with other users, and batch multiple updates together in one API call.
Installation is a single pip command, and the library requires Python 3.8 or later. The README provides many short code examples covering common tasks: finding cells by value, getting all data from a sheet as a list, updating ranges, and more. There is also a migration guide for users moving from version 5 to version 6, which changed the argument order of the main update method and how colors are specified.
The project is currently without active maintainers. The README notes that the team is looking for people to take over the project and points to a GitHub issue for anyone interested. The library is still installable and functional, but future updates depend on finding new maintainers.
Where it fits
- Automate data entry into a Google Sheet from a Python script instead of copy-pasting manually.
- Pull spreadsheet data into a Python program for analysis, reporting, or further processing.
- Update a shared Google Sheet with calculation results or API data from your code.
- Batch multiple cell writes in a single API call to efficiently update a dashboard or tracker sheet.