Error when importing terms from a CSV file in a Managed Metadata Service Application
01/27/2013 Leave a comment
Error:
When importing terms from a CSV file in a Managed metadata service application the following error is shown:
An error was encountered while attempting to import the term set at line 1001 of the submitted file and some data bay not have been cleaned up. Please ensure that this file is a valid CSV file and adhere to the correct format as in the sample file ImportTermSet.csv
Case:
A copy of the sample file ImportTermSet.csv was downloaded. That file is available on the Term Store Management Tool page for a Managed Metadata Service Application in Central Administration. In that sample file were added thousands of terms.
When trying to import terms in a group in the Taxonomy Term Store and choosing CSV file with thousands of terms
the following pop-up message was shown
Investigation:
My first thought was that maybe there is a limit for the number of terms that can be imported with one CSV file. Removed some of the terms and tried with different set of terms and I was still getting the same error message with error happening in different lines (not at line 1001 as in the first try).
I tried to import the terms with code. There is a property ImportManager.BatchSize with default value 1000. This property can be changed before calling the import method but that doesn’t fix anything because this property just sets the frequency of submitting the processed metadata.
In the end I when through the CSV files and I noticed some duplicate terms. After removing the duplicates the import succeeded.
Solution:
Make sure that there are no duplicate terms in the CSV file. Terms are case insensitive so case insensitive duplicates must be removed too.
Because there were thousands of terms I created a simple tool to remove the duplicates from the CSV file.