Menu

Pipe any Apify dataset into Google Sheets (and read a sheet back as JSON)
📰

Pipe any Apify dataset into Google Sheets (and read a sheet back as JSON)

DEV Community: tutorial·William Jin·13 days ago
#f9y5WzKF
#devtotutorial#devto#dev#gid#sheet
Reading 0:00
15s threshold

Most scraping jobs end in the same place: someone wants the rows in a spreadsheet. A recruiter wants new job posts, a marketer wants a list of competitor URLs, a founder wants leads they can sort and comment on. And often the reverse is needed too: a sheet of inputs (domains, keywords, product IDs) has to become JSON for the next script.

This post covers three ways to do it, and the details that trip people up along the way.

1. Reading a public sheet: the CSV export

If a sheet is shared as "Anyone with the link can view", you don't need an API key to read it. Every tab has a CSV export URL:

import csv , io , requests # pip install requests SHEET_ID = " 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms " # Google's public sample sheet url = f " https://docs.google.com/spreadsheets/d/ { SHEET_ID } /export?format=csv&gid=0 "

r = requests . get ( url , timeout = 30 ) r . raise_for_status () rows = list ( csv . DictReader ( io . StringIO ( r .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.