6 from configparser import ConfigParser
11 config_files = [f for f in os.listdir() if f.startswith('.taguette_gdocs')]
13 for file_path in config_files:
15 config = ConfigParser()
16 config.read(file_path)
18 ## this is project ID from the configuration
19 project_id = int(config['General']['taguette_project_id'])
20 taguette_database_file = config['General']['taguette_database_file']
22 # set output file name
23 output_file_name = f'exported_tags/exported_tags_{project_id}.tsv'
26 con = sqlite3.connect(taguette_database_file)
29 # Run this if you just want tags and no highlights
30 sql_stmt_get = "SELECT id, path, description FROM tags WHERE project_id = ?"
32 cur.execute(sql_stmt_get, (project_id,))
34 with open(output_file_name, 'w', newline='') as output_file:
35 writer = csv.writer(output_file, delimiter='\t')
36 writer.writerow(['id', 'axial codes', 'tag', 'category', 'description', 'url'])
43 tag_id, path, description = row
45 tag_match = re.match(r'^(.+)\_(.*)$', path)
47 axial = tag_match.group(1)
48 tag = tag_match.group(2)
53 # look for extra category information stored in the description
54 cat_match = re.match('^(.*)\s*(\{(.*)\})$', description)
56 description = cat_match.group(1)
57 category = json.loads(cat_match.group(2))["category"]
61 # create a URL that will link to the list of highlights
62 tag_url = urllib.parse.quote(tag)
63 url = f"https://taguette.communitydata.science/project/{project_id}/highlights/{tag_url}"
65 writer.writerow([str(tag_id), axial, tag, category, description, url])