Bulk Category Creation via CSV

AI-generated summary

Bulk Category Creation via CSV

Users are discussing the need for bulk category creation in Discourse. markersocial proposed a feature to support bulk category creation via CSV upload, similar to tag uploads. They suggested a simple CSV format with columns for category, subcategory, and description.

markersocial also referenced an existing solution using JSON files, but found it tedious to create and assign IDs correctly.

In response, pfaffman suggested writing a Ruby script to create categories from the console, which wouldn’t require IDs. They noted that categories can be created with just a name, but additional details like description and permissions can be added with more effort.

Heather_Dudley shared a similar experience, where a moderator used a script with an API key to bulk create categories, saving a significant amount of time (over 700 subcategories). They noted that the permissions part of the process was a bit tricky, but overall it was a huge timesaver.

I’ve been looking into bulk category creation.

The best I’ve found is this solution: Administrative Bulk Operations

Though creating those json files for the purpose of bulk creating new custom categories seems quite tedious unless you have some custom builder to create them and assign the ids correctly. Especially if working with any subcategories.

I think it would be a useful feature for Discourse to support bulk category creation via CSV upload, comparable to how tags are uploaded, formatted in a simple way. For example, like below:

Category Subcategory 1 Subcategory 2 Description
my custom parent category This category is a parent category
my custom parent category my custom subcategory This is a lvl 2 subcategory
my custom parent category my custom subcategory my custom sub-subcategory This is a lvl 3 subcategory

Expanding on this to include other custom options/columns could be considered as well.

Here is an example json entry for a category, when exported using this method: Administrative Bulk Operations

{
  "id": 1,
  "name": "Uncategorized",
  "color": "0088CC",
  "created_at": "2020-07-23T02:27:33.970Z",
  "user_id": -1,
  "slug": "uncategorized",
  "description": "",
  "text_color": "FFFFFF",
  "auto_close_hours": null,
  "position": 0,
  "parent_category_id": null,
  "auto_close_based_on_last_post": false,
  "topic_template": null,
  "all_topics_wiki": false,
  "permissions_params": {}
},
1 Like

It’s rare to need to create many categories, so the likelihood that whether interface there is well be to cumbersome to be worthwhile is high.

What I would do is write a ruby script to create the categories from the console. You don’t need any ID. I think you can create them with only the name, but you can also load the description, and permissions if you try hard.

4 Likes

When we did this, one of our mods ran a script with an API key to bulk create these en masse. It worked really well, although if I recall the permissions part was a little weird. Otherwise, it was a HUGE timesaver (we had over 700 subcategories to create).

4 Likes