Export a Google Sheets spreadsheet as a CSV file for local backup or processing.
Export a Google Sheets spreadsheet as a CSV file for local backup or processing.
Use this workflow when the user wants to back up spreadsheet data locally, export data for use in other tools, or create a CSV snapshot of a sheet.
Ask the user for the spreadsheet name or ID. If they provide a name, search for it:
gws drive files list \
--params '{"q": "name contains 'SHEET_NAME' and mimeType = 'application/vnd.google-apps.spreadsheet'"}' \
--fields "files(id,name)" --format table
Review what tabs and data ranges exist:
gws sheets spreadsheets get --params '{"spreadsheetId": "SHEET_ID"}' \
--fields "sheets.properties(sheetId,title)"
Option A — Export via Drive API (downloads the first sheet as CSV):
gws drive files export --params '{"fileId": "SHEET_ID", "mimeType": "text/csv"}'
Option B — Read values directly (more control over range and format):
gws sheets +read --spreadsheet SHEET_ID --range 'Sheet1' --format csv
Show the user the output path and a preview of the data.
+read) when you need a specific tab or range--format csv for machine-readable output, --format table for a quick visual check