I’m trying to work out how to read the data of a DataTable with Python. My code starts with the “asset path” for the DataTable.
I would have thought you would use DataTableRowHandle, but I can’t actually find any “use” for it, and it doesn’t seem to have any method that returns the “content” of the row either. In other words, it’s basically useless in Python atm.
Although I haven’t yet found a way to list the “column names” of a DataTable, or the “fields” of the underlying UserDefinedStruct in Python. at least, the doc talks about “DataTableFunctionLibrary.get_data_table_column_as_string()”. Unfortunately, it doesn’t even seem to work. Am I doing something wrong, or is it buggy?
datatable_func_lib = unreal.DataTableFunctionLibrary()
string_lib = unreal.StringLibrary()
editor_asset_lib = unreal.EditorAssetLibrary()
# Path to table
asset_path = ...
# The table object
table = editor_asset_lib.load_asset(asset_path)
# Name of desired table column, as String
col_name_str = 'my_col'
# Name of desired table column, as Name
col_name = string_lib.conv_string_to_name(col_name_str)
# This works
row_names = datatable_func_lib.get_data_table_row_names(table)
# This is always an empty array
my_col_values = datatable_func_lib.get_data_table_column_as_string(table, col_name)
Off-Topic: Why am I not allowed to post, if I use “DataTableFunctionLibrary.get_data_table_column_as_string()” in the title?!?
Depends on what you call a solution. As you can see, nobody else replied, so I assume it’s just not possible. So I gave up and started reading the “source” CSV files instead. As long as both are kept in sync, which is only easy for me because I’m the only dev, than I access the data that way.
There is a getDataTableRow function in the blueprint but it is not exposed in python.
There might be some technical limitations preventing to expose it.
I logged it in the system Unreal Engine Issues and Bug Tracker (UE-131103).