Accessing Attributes
How to access attributes on exports and file streaming
Attributes can be available either at the instance level or at the file level.
General Attributes Format
Both instance and global attributes follow the following format:
{
<ATTRIBUTE_ID>: attribute_data_goes here
}
The <ATTRIBUTE_ID>
key corresponds to the attribute ID on the schema. You can determine what is the attribute name by querying the attribute ID on the schema via 2 options:
- If you generated a JSON export, you can check the
attribute_groups_reference
key to get the full info of the attribute. - If you are using the Python SDK you can use the call
project.get_attributes_list()
Get Attributes List
Instance Level Attributes
Each instance object will have a attribute_groups
key where you will see all the attributes added to the specific instance.
Global File Attributes
For global attributes there is a special key global_attributes
this key will contain a dictionary where the ID corresponds to the attribute ID and the value to the selected option for the given attribute.
For example, when streaming data, to access a specific attribute you would need to do the following
file_data = dataset[0]
# Get the raw instance list
file_data['raw_instance_list']
# Get the global attributes
file_data['raw_instance_list']['global_attributes']
# Get the attibute with ID 54
file_data['raw_instance_list']['global_attributes']['54']
Updated about 2 years ago