system.tag.exportTags
This function is used in Python Scripting.
Description​
Exports tags to a file on a local file system.
The term "local file system" refers to the scope in which the script was running; for example, running this script in a Gateway Timer script will export the file to the Gateway file system.
Client Permission Restrictions​
This scripting function has no Client Permission restrictions.
Syntax​
note
This function accepts keyword arguments.
system.tag.exportTags([filePath], tagPaths, [recursive], [exportType])
Parameters​
Type | Parameter | Description |
---|---|---|
String or Nothing | filePath | The file path that the tags will be exported to. If the file does not already exist, this function will attempt to create it. ​ Changed in 8.1.8 Previously, the filePath parameter was required. If omitted, causes the function to return the tag export as a string. |
List | tagPaths | A List of tag paths to export. All tag paths in the list must be from the same parent folder. |
Boolean | recursive | Set to true to export all tags under each tag path, including tags in child folders. Defaults to true. [optional] |
String | exportType | The type of file that will be exported. Set to "json" or "xml". Defaults to "json". |
Returns​
Nothing
Scope​
Gateway, Vision Client, Perspective Session
Code Examples​
Example #1
# This example attempts to export the entire Tag Provider, including UDT definitions.
# The filepath is Operating System dependent, so the path notation below may differ based on where the function is called from.
filePath = 'C:\\Users\\myUser\\Desktop\\myTags'
tagPaths = ["[default]"]
recursive = True
system.tag.exportTags(filePath, tagPaths, recursive)
Example #2
# Exports the entire tag provider named "default" as a string, and
# returns the string to a "tags" variable.
tags = system.tag.exportTags(tagPaths = ["[default]"])
Example #3
# Exports all UDTs from the _types_ folder of a specific Tag Provider into a single file.
filePath = 'C:\\UDTExports\\MyUDTs.json'
tagPaths = ["[provider]_types_"]
system.tag.exportTags(filePath, tagPaths)