create the db file from the google doc

This commit is contained in:
iamBadgers
2024-06-08 21:31:07 -07:00
parent 395c06e88e
commit 7fa18b15a1
5 changed files with 231 additions and 97 deletions

View File

@@ -0,0 +1,31 @@
import os
import requests
import sys
DOCUMENT_ID = '1VKujaowUSxB9SuBdMt81aFlUGWo2fUCAOzX2PjYQVxs'
GAME_SHEET_ID = '160661246'
CHARACTTER_SHEET_ID = '1445780435'
def getGoogleSheet(spreadsheetId, sheetId, outFile):
url = f'https://docs.google.com/spreadsheets/d/{spreadsheetId}/export?gid={sheetId}&format=csv'
response = requests.get(url)
if response.status_code == 200:
filepath = os.path.join('./', outFile)
with open(filepath, 'wb') as f:
f.write(response.content)
print('CSV file saved to: {}'.format(filepath))
else:
print(f'Error downloading sheet: {response.status_code}')
sys.exit(1)
def downloadGamesCSV(outFile):
getGoogleSheet(DOCUMENT_ID, GAME_SHEET_ID, outFile)
def downloadCharactersCSV(outFile):
getGoogleSheet(DOCUMENT_ID, CHARACTTER_SHEET_ID, outFile)
if __name__ == "__main__":
getGoogleSheet('1VKujaowUSxB9SuBdMt81aFlUGWo2fUCAOzX2PjYQVxs', '1445780435', './here', 'potato')