This functionality is only available for certain module packages.

You are here: Tutorial > Project generation per import > Part 3 - Writing values into parameters by importing a CSV file > Writing values into individual parameters by importing a CSV file

Writing values into individual parameters by importing a CSV file

Requirements:

In addition to the system libraries, the library catalog contains the architecture T_Mechatronic_Architecture and the modular system T_Mechatronic_ModularSystem.

The Feeder project exists in the Project catalog.

The CSV file Parameter.csv is imported in order to set parameter values in the existing configuration. To this purpose the template file Template_CSV.imx is additionally required.

Note:

Identically structured Excel files can be imported with the identically template and scheme files.

Proceed as follows to set parameter values:

  1. Select the menu item File > Import....
  2. The import wizard opens with the Select page.

  3. Navigate to Project > Import.
  4. Confirm via [Next >].
  5. The import wizard opens the page Import file.

  6. Specify the file Parameter.csv in the Source file name field.
  7. The file is located in the following directory:

    <EEC installation path>\resources\Import\CSV

    Use [Browse...] to navigate to the file. If appropriate, select the filter Excel workbooks (*.xls, *.xlsx, *.xlsm).

  8. Select Default:Parameter.xsl from the drop-down list. This grays out the input field.
  9. Enter the file Template_CSV.imx in the Template file name field.
  10. The file is located in the following directory:

    <EEC installation path>\resources\Import\IMX

    Use [Browse...] to navigate to the file. If applicable, select the file filter IMX files (*.imx).

  11. Remove the Create new project option and mark the Feeder project in the list below it.
  12. Confirm with [Finish].

Result:

The configuration called Feeder is displayed in the project catalog:

  1. Open the Feeder component.
  2. Select the Parameters editor.

The Value column shows that all the values from the CSV file have been imported as String.

The ParameterBoolean parameter is filled with the value ='true'. Since this is not a valid Boolean value, false is entered as the result.

Formula errors are displayed for the parameters ParameterDouble and ParameterInteger because the imported values cannot be interpreted as Double or Integer respectively.

The ParameterMap parameter is not filled by the import and is therefore <<null>>.

Solely the ParameterString parameter is set correctly with the value Hello World.

In other words:

The third column of the CSV value is not detected during the conversion and consequently all the imported values are interpreted as a string.

If the parameters are imported with the correct type, the scheme file for the transformation of the CSV file into a fragment has to be customized.

Proceed as follows to change the XSL file:

  1. Copy the <EEC installation path>\install\importschemas\Parameter.xsl file into the following folder:
  2. <EEC installation path>\resources\Import\XSL
  3. Rename the file to ParameterWithType.xsl.
  4. Open the file ParameterWithType.xsl with any editor, for example Notepad++.
  5. Navigate to the <xsl:template match="row" > tag in the file.

Appearance before the change:

<xsl:template match="row" >
	<xsl:choose>
		<xsl:when test="@number > $LineEndHeader ">
			<xsl:element name="parameter">
				<xsl:attribute name="name">
					<xsl:value-of select="col[@number='1']"/>
				</xsl:attribute>
				<xsl:attribute name="value">
					<xsl:value-of select="col[@number='2']"/>
				</xsl:attribute>
			</xsl:element>
		</xsl:when>
		<xsl:otherwise>
		</xsl:otherwise>
		</xsl:choose>
</xsl:template>

Insert the following rows at the end of the block of <xsl:element name="parameter">:

<xsl:attribute name="type">
	<xsl:value-of select="col[@number='3']"/>
</xsl:attribute>

The result should look as follows:

<xsl:template match="row" >
	<xsl:choose>
		<xsl:when test="@number > $LineEndHeader ">
			<xsl:element name="parameter">
				<xsl:attribute name="name">
					<xsl:value-of select="col[@number='1']"/>
				</xsl:attribute>
				<xsl:attribute name="value">
					<xsl:value-of select="col[@number='2']"/>
				</xsl:attribute>
				<xsl:attribute name="type">
					<xsl:value-of select="col[@number='3']"/>
				</xsl:attribute>
			</xsl:element>
		</xsl:when>
		<xsl:otherwise>
		</xsl:otherwise>
		</xsl:choose>
</xsl:template>

Import with the modified scheme file ParameterWithType.xsl:

  1. Select the menu item File > Import....
  2. The import wizard opens with the Select page.

  3. Navigate to Project > Import.
  4. Confirm via [Next >].
  5. The import wizard opens the page Import file.

  6. Specify the file Parameter.csv in the Source file name field.
  7. The file is located in the following directory:

    <EEC installation path>\resources\Import\CSV

    Use [Browse...] to navigate to the file. If appropriate, select the filter Excel workbooks (*.xls, *.xlsx, *.xlsm).

  8. Select Customer scheme from the drop-down list. Specify the modified scheme file.
  9. <EEC installation path>\resources\Import\XSL\ParameterWithType.xsl

    Use [Browse...] to navigate to the file. If applicable, select the file filter Scheme XSL files (*.xsl, *.xslt).

  10. Enter the file Template_CSV.imx in the Template file name field.
  11. The file is located in the following directory:

    <EEC installation path>\resources\Import\IMX

    Use [Browse...] to navigate to the file. If applicable, select the file filter IMX files (*.imx).

  12. Remove the Create new project option and mark the Feeder project in the list below it.
  13. Confirm with [Finish].

Result:

The configuration called Feeder is displayed in the project catalog:

  1. Open the Feeder component.
  2. Open the Parameter editor.

The Values column shows that all the values from the CSV file have been imported with their own types.

The ParameterMap parameter is not filled by the import and is therefore <<null>>.