When importing categories, the Group Name can be specified as a corresponding column to the category. This updates the Group Name automatically when the category is created. It can also be used to change the Group Name of an existing category.
Specify the Group Name as "categorygroup1" for "category1", "categorygroup2" for "category2" and so on. This screenshot shows an example spreadsheet and the results in the Category administrative screen.