Add rows to UDataTable at runtime with c++ code

@anonymous_user_4aa5607e1 pointed me in the right direction

@philippn_vfx if you want to import data from text then FDataTableImporterCSV::ReadTable() is great to learn, but if you have created your custom Row class deriving from FTableRowBase then all code from that method could be simplified into simple loop:

TArray<FYourRowStruct> DataToInsert;

for (int32 RowIdx = 0; RowIdx < DataToInsert.Num(); RowIdx++)
	{
		// Get row name
		FName RowName = DataTableUtils::MakeValidName(FString::Printf(TEXT("%d"),RowIdx + 1));
		DataTable->AddRow(RowName, DataToInsert[RowIdx]);//This will remove existing rows with this name if found
}
1 Like