]> code.communitydata.science - taguette_google_sheet_integration.git/blob - taguette-export_tags_to_csv.py
initial import of stuff into google sheets
[taguette_google_sheet_integration.git] / taguette-export_tags_to_csv.py
1 #!/usr/bin/env python3
2
3 import re
4 import sqlite3
5
6 ## connect to sqlite3
7 con = sqlite3.connect('taguette-working.sqlite3')
8 cur = con.cursor()
9
10 ## this is the hardcoded project id
11 project_id = 13
12
13 sql_stmt_get = "SELECT id, path, description FROM tags WHERE project_id = ?"
14 cur.execute(sql_stmt_get, (project_id,))
15
16 while True:
17     row = cur.fetchone()
18     if row == None:
19         break
20         
21     tag_id, path, description = row
22
23     m = re.match(r'^(.+)\.(.*)$', path)
24     if m:
25         axial = m.group(1)
26         tag = m.group(2)
27     else:
28         axial = ""
29         tag = path
30     
31     print("\t".join([str(tag_id), axial, tag, description]))
32

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