1.14. CSV metadata import

DHIS2 supports import of metadata in the CSV format. Columns which are not required can be omitted in the CSV file, but the order will be affected. If you would like to specify columns which appear late in the order but not specify columns which appear early in the order you can include empty columns ("") for them. The following object types are supported:

The formats for the currently supported object types for CSV import are listed in the following sections.

1.14.1. Data elements

Table 1.13. Data Element CSV Format

ColumnRequiredValue (default first)Description
NameYes Name. Max 230 char. Unique.
UIDNoUIDStable identifier. Exactly 11 alpha-numeric characters, beginning with a character. Will be generated by system if not specified.
CodeNo Stable code. Max 50 char.
Short nameNo50 first char of nameWill fall back to first 50 characters of name if unspecified. Max 50 char. Unique.
DescriptionNo Free text description.
Form nameNo Max 230 char.
Domain typeNoAGGREGATE | TRACKERDomain type for data element, can be aggregate or tracker. Max 16 char.
Value typeNoINTEGER | NUMBER | UNIT_INTERVAL | PERCENTAGE | INTEGER_POSITIVE | INTEGER_NEGATIVE | INTEGER_ZERO_OR_POSITIVE | FILE_RESOURCE | COORDINATE |TEXT | LONG_TEXT | LETTER | PHONE_NUMBER | EMAIL | BOOLEAN | TRUE_ONLY | DATE | DATETIME Value type. Max 16 char.
Aggregation operatorNoSUM | AVERAGE | AVERAGE_SUM_ORG_UNIT | COUNT | STDDEV | VARIANCE | MIN | MAX | NONEOperator indicating how to aggregate data in the time dimension. Max 16 char.
Category combination UIDNoUIDUID of category combination. Will default to default category combination if not specified.
UrlNo URL to data element resource. Max 255 char.
Zero is significantNofalse | trueIndicates whether zero values will be stored for this data element.
Option setNoUIDUID of option set to use for data.
Comment option setNoUIDUID of option set to use for comments.

An example of a CSV file for data elements can be seen below. The first row will always be ignored. Note how you can skip columns and rely on default values to be used by the system. You can also skip columns which you do not use which appear to the right of the ones

name,uid,code,shortname,description
"Women participated in skill development training",,"D0001","Women participated development training"
"Women participated in community organizations",,"D0002","Women participated community organizations"

1.14.2. Organisation units

Table 1.14. Organisation Unit CSV Format

ColumnRequiredValue (default first)Description
NameYes Name. Max 230 characters. Unique.
UIDNoUIDStable identifier. Max 11 char. Will be generated by system if not specified.
CodeNo Stable code. Max 50 char.
Parent UIDNoUIDUID of parent organisation unit.
Short nameNo50 first char of nameWill fall back to first 50 characters of name if unspecified. Max 50 characters. Unique.
DescriptionNo Free text description.
Opening dateNo1970-01-01Opening date of organisation unit in YYYY-MM-DD format.
Closed dateNo Closed date of organisation unit in YYYY-MM-DD format, skip if currently open.
CommentNo Free text comment for organisation unit.
Feature typeNoNONE | MULTI_POLYGON | POLYGON | POINT | SYMBOLGeospatial feature type.
CoordinatesNo Coordinates used for geospatial analysis in Geo JSON format.
URLNo URL to organisation unit resource. Max 255 char.
Contact personNo Contact person for organisation unit. Max 255 char.
AddressNo Address for organisation unit. Max 255 char.
EmailNo Email for organisation unit. Max 150 char.
Phone numberNo Phone number for organisation unit. Max 150 char.

A minimal example for importing organisation units with a parent unit looks like this:

name,uid,code,parent
"West province",,"WESTP","ImspTQPwCqd"
"East province",,"EASTP","ImspTQPwCqd"

1.14.3. Validation rules

Table 1.15. Validation Rule CSV Format

ColumnRequiredValue (default first)Description
NameYes Name. Max 230 characters. Unique.
UIDNoUIDStable identifier. Max 11 char. Will be generated by system if not specified.
CodeNo Stable code. Max 50
DescriptionNo Free text description.
InstructionNo Free text instruction.
ImportanceNoMEDIUM | HIGH | LOW 
Rule typeNoVALIDATION | SURVEILLANCE 
OperatorNoequal_to | not_equal_to | greater_than | greater_than_or_equal_to | less_than | less_than_or_equal_to | compulsory_pair | exclusive_pair 
Period typeNoMonthly | Daily | Weekly | Quarterly | SixMontly | Yearly 
Left side expressionYes Mathematical formula based on data element and option combo UIDs.
Left side expression descriptionYes Free text.
Left side null if blankNofalse | trueBoolean.
Right side expressionYes Mathematical formula based on data element and option combo UIDs.
Right side expression descriptionYes Free text.
Right side null if blankNofalse | trueBoolean.

1.14.4. Option sets

Table 1.16. Option Set CSV Format

ColumnRequiredValue (default first)Description
OptionSetNameYes Name. Max 230 characters. Unique. Should be repeated for each option.
OptionSetUIDNoUIDStable identifier. Max 11 char. Will be generated by system if not specified. Should be repeated for each option.
OptionSetCodeNo Stable code. Max 50 char. Should be repeated for each option.
OptionNameYes Option name. Max 230 characters.
OptionUIDNoUIDStable identifier. Max 11 char. Will be generated by system if not specified.
OptionCodeYes Stable code. Max 50 char.

The format for option sets is special. The three first values represent an option set. The three last values represent an option. The first three values representing the option set should be repeated for each option.

optionsetname,optionsetuid,optionsetcode,optionname,optionuid,optioncode
"Color",,"COLOR","Blue",,"BLUE"
"Color",,"COLOR","Green",,"GREEN"
"Color",,"COLOR","Yellow",,"YELLOW"
"Sex",,,"Male",,"MALE"
"Sex",,,"Female",,"FEMALE"
"Sex",,,"Uknown",,"UNKNOWN"
"Result",,,"High",,"HIGH"
"Result",,,"Medium",,"MEDIUM"
"Result",,,"Low",,"LOW"
"Impact","cJ82jd8sd32","IMPACT","Great",,"GREAT"
"Impact","cJ82jd8sd32","IMPACT","Medium",,"MEDIUM"
"Impact","cJ82jd8sd32","IMPACT","Poor",,"POOR"

1.14.5. Collection membership

In addition to importing objects, you can also choose to only import the group-member relationship between an object and group. Currently the following group and object pairs are supported

  • Organisation Unit Group - Organisation Unit

  • Data Element Group - Data Element

  • Indicator Group - Indicator

The CSV format for these imports are the same

Table 1.17. Collection membership CSV Format

ColumnRequiredValue (default first)Description
UIDYesUIDThe UID of the collection to add an object to
UIDYesUIDThe UID of the object to add to the collection


1.14.6. Other objects

Table 1.18. Data Element Group, Category Option, Category Option Group, Organisation Unit Group CSV Format

ColumnRequiredValue (default first)Description
NameYes Name. Max 230 characters. Unique.
UIDNoUIDStable identifier. Max 11 char. Will be generated by system if not specified.
CodeNo Stable code. Max 50 char.
Short nameNo Short name. Max 50 characters.

An example for category options looks like this:

name,uid,code,shortname
"Male",,"MALE"
"Female",,"FEMALE"