I'm using a Google Spreadsheet document to configure a data-driven program.

The program consumes a CSV file, which now I have to export manually from the document. It is rather inconvenient, as everything else is automated.

I'd like to export the CSV file using a bash-script.

How do I do that?


1 Answer 1


Doing it from bash is very straightforward. All you need to do is run:

curl -s -d /dev/null https://docs.google.com/spreadsheets/d/DOCUMENT_ID/export?exportFormat=csv > mydocument.csv
dos2unix mydocument.csv 2> /dev/null

This only works for publicly shared documents though. To have access to private documents you will need to use OAuth2. You can find information about doing that here and then you can Google how to use OAuth2 with curl. (Because for the time being I can only post 1 URL at a time)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.