Split all tags? Sort tags by length?
I have a large list of records that includes a ton of badly formatted entries. As a result, tag lists use inconsistent formatting and when imported, often wind up as one giant conglomeration of tags instead of separate tags. These are too big for the database, and crash the Zotero client when I try to edit them during a sync.
Is there a way to split the entire tag list? Or alternatively, to sort the tag list by tag length so I can see which ones are overly large?
Is there a way to split the entire tag list? Or alternatively, to sort the tag list by tag length so I can see which ones are overly large?
https://forums.zotero.org/discussion/97395/is-there-any-way-to-get-a-list-of-current-tags
If scrolling through that list is too difficult to find the long tags (you could copy and paste the list into a text editor or word processor to make viewing easier), then there are various ways to sort a text list by line length ... eg
https://onlinetexttools.com/sort-text-lines
https://www.browserling.com/tools/line-length-sort
PS Forget that. ;) I just modified the code there to produce a list of tags sorted by length ...
var rows = await Zotero.DB.queryAsync("SELECT name AS tagname, COUNT(*) AS num FROM tags JOIN itemTags USING (tagID) GROUP BY tagname ORDER BY LENGTH(tagname) DESC");
var lines = [];
for (let row of rows) {
lines.push(row.tagname + '\t' + row.num);
}
return lines.join('\n');