5 from configparser import ConfigParser
9 config_files = [f for f in os.listdir() if f.startswith('.taguette_gdocs_')]
11 for file_path in config_files:
13 config = ConfigParser()
14 config.read(file_path)
16 ## this is project ID from the configuration
17 project_id = int(config['General']['taguette_project_id'])
18 taguette_database_file = config['General']['taguette_database_file']
20 # set output file name
21 output_file_name = f'exported_tags/exported_tags_{project_id}.tsv'
24 con = sqlite3.connect(taguette_database_file)
27 # Run this if you just want tags and no highlights
28 sql_stmt_get = "SELECT id, path, description FROM tags WHERE project_id = ?"
30 # Run this if you want tags AND highlights
31 #sql_stmt_get = "SELECT tags.id, tags.path, tags.description, highlights.snippet FROM highlight_tags INNER JOIN tags ON highlight_tags.tag_id = tags.id INNER JOIN highlights ON highlight_tags.highlight_id = highlights.id WHERE project_id = ?"
32 cur.execute(sql_stmt_get, (project_id,))
35 with open(output_file_name, 'w', newline='') as output_file:
36 writer = csv.writer(output_file, delimiter='\t')
42 tag_id, path, description = row
44 m = re.match(r'^(.+)\_(.*)$', path)
52 writer.writerow([str(tag_id), axial, tag, description])