I am trying to use bash to download google sheets as a csv file. I have it working, however its just downloading the HTML contents, not the actual cell value.
How can I use bash to download google sheets contents as a CSV File without HTML?
Below is what I have tried, and it all outputs the same. Just HTML, no cell values.
wget --no-check-certificate --output-document=import.csv 'https://docs.google.com/spreadsheets/d/1OTAyEgUTh4fNIs5SsoxuF8Nd7JqS6iPISFSHh-tS85M/edit#gid=809903748'
curl -s -d /dev/null https://docs.google.com/spreadsheets/d/1OTAyEgUTh4fNIs5SsoxuF8Nd7JqS6iPISFSHh-tS85M/edit?usp=sharing/export?exportFormat=csv > import.csv dos2unix mydocument.csv 2> /dev/null
wget --no-check-certificate -r "https://docs.google.com/spreadsheets/d/1OTAyEgUTh4fNIs5SsoxuF8Nd7JqS6iPISFSHh-tS85M/edit#gid=809903748" -O "import.csv"
wget -O ./import.csv "https://docs.google.com/spreadsheets/d/1OTAyEgUTh4fNIs5SsoxuF8Nd7JqS6iPISFSHh-tS85M/edit#gid=809903748"
Try this :
wget --no-check-certificate --output-document=import.csv "https://docs.google.com/spreadsheets/d/1OTAyEgUTh4fNIs5SsoxuF8Nd7JqS6iPISFSHh-tS85M/export?format=csv"
The command that @Philippe provided (wget --no-check-certificate --output-document=import.csv "https://docs.google.com/spreadsheets/d/<sheet_id>/export?format=csv") works.
Make sure that your sheet is "Public on the web".
To do so, go to Share. In the section "Get Link", click on "Change" and set "Anyone with the link" --> viewer
This command should work:
curl -L "https://docs.google.com/spreadsheets/d/1OTAyEgUTh4fNIs5SsoxuF8Nd7JqS6iPISFSHh-tS85M/export?gid=809903748&format=csv" > import.csv
The question is answered in this post [1] for more information.
[1] https://stackoverflow.com/questions/24255472/download-export-public-google-spreadsheet-as-tsv-from-command-line/28494469#28494469