]> code.communitydata.science - taguette_google_sheet_integration.git/blobdiff - taguette-update_tags_from_sheet.py
added new configuration file and README
[taguette_google_sheet_integration.git] / taguette-update_tags_from_sheet.py
index 036d04dc5c1af04442dcec3296b0f111d8469980..5c529917f6d37c031452bcad587cee013bba7e4e 100755 (executable)
@@ -3,13 +3,18 @@
 import requests
 from csv import DictReader
 import sqlite3
+from configparser ConfigParser
 
-gsheet_id = "1bfKljA7vw2V4yKrowxCPLdYaBrTzty5_O7msbuFw7Nc"
-gsheet_gid = "0"
+config = ConfigParser()
+config.read('.taguette_gdocs')
 
-## this is the hardcoded project id
-project_id = 13
+## this is project ID from the configuration
+project_id = int(config['General']['taguette_project_id'])
+taguette_database_file = config['General']['taguette_database_file']
 
+## load the googgle sheet ID from the configuration
+gsheet_id = config['General']['gsheet_id']
+gsheet_gid = config['General']['gsheet_gid']
 
 ## get the spreadsheet data
 axial_url = f"https://docs.google.com/spreadsheets/d/{gsheet_id}/export?format=csv&id={gsheet_id}&gid={gsheet_gid}"
@@ -17,7 +22,7 @@ rv = requests.get(axial_url)
 csv_text = rv.content.decode('utf-8')
 
 ## connect to sqlite3
-con = sqlite3.connect('taguette-working.sqlite3')
+con = sqlite3.connect(taguette_database_file)
 cur = con.cursor()
 
 ## import taguette.database as tagdb

Community Data Science Collective || Want to submit a patch?