Import and Export Things
How to import and export Things into the IoTHub Using CSV Files
In this guide you will learn how to use the IoTHub to import and export Things configuration into and out of the iothub.
It is primarily intended to get information about a Things configuration.
TIP
Additionally, the REST API can be used to import and export Things.
Note
These are experimental features and may change in the future. The import does not work for things with special attributes.
Using the Web Frontend
Import
In the web frontend, you can import and export Things by navigating to the Things page. Click the hamburger menu and select Import. The import expects a CSV file with the structure described below. The export will return a CSV file with the same structure.
CSV Structure
The CSV file needs the following structure (header and first content line)
Thing,Thing-type,property,type,minimum,maximum,unit,read-only,title,attribute0,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9
opa,opc.ua,pro1,string,,,points,,Prop-property,namespace=0,identifier_type=String,identifier=identify,,,,,,,,
The delimiter, e.g ,
can be one of the following: ;
,
and |
Empty cells can be left blank.
There is a special handling for the optional fields minimum, maximum, unit and title. If they contain null (as shown in the excel example image) you can reset them. E.g. an empty title field means the title is not set in the csv (as title is an optional field).
If you have accidentally set a wrong title and you want to set the title back to an empty string you can do this by setting the title field to null. This goes beyond simple creation as it is only relevant if you want to change an already existing property.
Each row is a property to create with its corresponding Thing. A not existing Thing will be created first.
The fields attribute0 to attribute9 contain configuration attributes of a property specific to the type of technology. They are formatted as key value pairs separated by an =
.
Note
Each attribute field can only contain one attribute. Attributes are case sensitive.
The columns have the following properties described in the table below.
TIP
Have a look at this article for more information about possible Thing and data types.
Column name | Thing | Thing-type | property | type | minimum | maximum | unit | read-only | title | attribute0 to attribute9 |
---|---|---|---|---|---|---|---|---|---|---|
Description | The name of the Thing (to create if not exists) | type of the Thing (virtual, opc.ua) | name of the property | type of the property (string, array) | minimum value (for numeric types) | maximum value | Optional unit of the property | describes if property is read-only | human readable title | configuration attributes of the property |
Data type | string | string | string | string | number | number | string | boolean | string | string |
Required | Yes | Yes | Yes | Yes | No | No | No | No | No | Depends on configuration requirements of the property |
Example | sawMill1 | virtual.virtual | temperature | float64 | 0 | 100 | °C | false | Saw Mill | addressing=I0.2 |
Export
Clicking on the export button will return a CSV file with the same structure as the import. The downloaded file can then be opened in excel for further editing.