Skip to content
Igor Rutka edited this page Jul 10, 2023 · 3 revisions

With the "CSV Import Agent" you can import Assets from a .csv file. Comma Separated Values (CSV) files can be exported from your spreadsheet. We will show an example using Google Sheets.

Example: Import Assets from CSV file

An overview of the steps:

  1. Create a correctly formatted CSV file
  2. Import the Assets to OpenRemote

1. Create CSV file

In this example we will create an CSV file from a spreadsheet with the use of Google Sheets

  1. Go to Google Drive and create a new spreadsheet. In this example we use "United States" formatting. If you want to check your format style go to: file > Settings. If you use different format settings some things might differ from this example
  2. Next fill in your spreadsheet. The figure below shows the correct format for Asset import.

Row 1 is used for notes. You can write notes to add additional information about the spread sheet. The content of row 1 is ignored by the CSV Import Agent.

Row 2 is used for attribute names. The attribute names should follow the naming convention as shown in the figure. If you are not sure jet how you want to name your attributes you can for example fill in: row1, row2, ... in those fields

Row 3 is used for the Value type of your attributes. In the table below you can find an overview of all available value types. If you are not sure what your value type is you can put in TEXT in the fields for now. If you want to exclude a column (eg you don't want to create an attribute from this column) write EXCLUDE)

When you made all your assets it is time to export your google sheet to a CSV file. Go to File > Download > Comma Separated Values (.csv). For our example we get the following content of the CSV file. You can also directly copy this to a text editor and save it with a .csv file extension.

In the next section we will explain how to import the assets from your CSV file

2. Import Assets

Login to your OpenRemote Manager and go to the Assets tab. Click on the + icon and select the CSV Import Agent. Give it the name "Example: CSV Import Agent" and click ADD.

There are a couple options for asset import from your CSV file.

The first one is "selectAssetType". We will use the default "ThingAsset" type. *(Developers: if you have created your own custom asset you can select it. You can also create a copy of the CSV import Agent and add additional assetTypes. Link to custom project)

The next option is "useFirstColumnForAssetName". If you select this option the first column of your CSV file will be used for the asset names. Be aware that multiple assets can have the same name if you have duplicate asset names in your CSV file. In the logs you can find if there were duplicate asset name imports and which row of the csv file is the duplicate asset name. If you leave this option unchecked by default the assets will be named: Asset Row 3, Asset Row 4, ...

The last option is "useFirstColumnForAssetID". At asset creation an Asset ID is generated. When this box is unchecked this each assets get a random asset ID. When the box is checked the first column of your CSV file will be used to generate asset ID's. When the CSV Import Agent encounters a duplicate asset ID it will not import that row. In the logs you can find if there were duplicate asset ID's imports and which row of the CSV file is the duplicate asset ID. As long as your asset names are unique you can use those also as the asset ID's.

Clone this wiki locally