.. highlightlang:: us .. index:: Browser=>Filter Channel Names .. _browser-nc_name_filter: Browser=>Filter Channel Names ----------------------------- This command can be used to rename channel names in NC files. To access the command right click inside the NC Editor. .. image:: S:/uniplot-obj/images/nc_name_filter-en.* .. us.dialog .. us.dlgitem **Original Name** Original channel name in the original data file. .. us.dlgitem **Channel Name** Channel name in the netCDF data file. .. us.dlgitem **Show Device Names** For MDF files the device name is added to the channel name, separated by a backslash (``aaa.bbb\device``). If the option is not selected, the device name is removed (``\device``). .. us.dlgitem **First Filter** The first filter can be used to split the channel name at the separator charachter. Elements can be removed at the beginning or the end of the name. More filter of this type can be specified in the text box. .. us.dlgitem **Execute** The filter is applied and the result is displayed in the Channel Name column. .. us.dlgitem **More Filters** If *More Filters* is enabled, filter can be specified in the text box, one filter in each line. Each filter has the following form: match filter-name parameter To disable a filter, add a comment character ``#`` at the beginning of a line. match: In front of the ``filter-name`` an optionial search pattern can be set. see :ref:`strmatch`. The search pattern must end with a ``@`` character. Example: .. code-block:: none es_* @ upper All channels starting with ``es_`` will be converted to upper case. .. code-block:: none *_[1-3] @ lower All channels starting with ``_1``, ``_2`` or ``_3`` will be converted to lower case. filter-name .. list-table:: :header-rows: 1 * - Name - Description * - separator - Splits the channel name at a separator in tokens. ``separator`` has three parameters: Separator, Number (range 0 to 9) and action (one of the four strings: ``hide from right``, ``show from right``, ``hide from left``, ``show from left``). .. code-block:: none separator . 1 show from right aaa.bbb => bbb a.b.c => c .. code-block:: none separator . 1 hide from right aaa.bbb => aaa a.b.c => a.b * - lower - Changes the case to small characters. * - upper - Changes the case to upper characters. * - replace - Replaces the text. Example: .. code-block:: none replace . _ aaa.bbb => aaa_bbb TIME* @ replace TIME_ Time TIME_1 => Time1 * - remove - Removes characters. The command can remove all occurrences, remove characters at the beginning (from left) or at the end (from right) of the name. Example: .. code-block:: none remove $ $aaa.bbb => aaa.bbb remove .ext from right x122.ext => x122 remove mot_ from left mot_n => n .. us.dialog **Use new names for attribute long_name and title** If this option is marked the new name is used to update the channel attributes long_name and title. .. us.dlgitem .. us.example **Example** The following example automates the channel name filtering. The function OnImportUpdateNCFile is a callback function, that will be invoked if defined. In this example it is checked, if the data file was created with the ODS5 import filter and contains a certain value in a global attribute. The filter fucntion ``nc_name_filter`` removes the characters ``Ext`` from the end of the channel name. The first function parameter is a vector with all channel names. The second paramete is the filter string:: def OnImportUpdateNCFile(ssNCName) { ncid = nc_open(ssNCName, NC_WRITE); if (ncid == -1) { return FALSE; } if (nc_attinq_datatype(ncid, -1, "TestCell") != NC_CHAR) { nc_close(ncid); return TRUE; } ssAtt = nc_attget(ncid, -1, "TestCell"); if (strfind(ssAtt, "Xp2")[1] == 0) { nc_close(ncid); return TRUE; } if (nc_attinq_datatype(ncid, -1, "Creator") != NC_CHAR) { nc_close(ncid); return TRUE; } ssAtt = nc_attget(ncid, -1, "Creator"); if (strfind(ssAtt, "ODS51")[1] == 0) { nc_close(ncid); return TRUE; } if (_nc_need_org_name(ncid)) { _nc_write_org_names(ncid); } sv = NC_GetOrgNames(ncid); // remove the string "Mit" from the string end. sv = nc_name_filter(sv, "remove Ext from right"); _nc_rename_all(ncid, sv, TRUE); nc_close(ncid); return sv; } .. us.comment **Comment** **Kommentar** New filter functions can be added. See file :file:`nc_name_filter.ic`. .. seealso:: :ref:`the-data-browser` :sub:`id-781728`