How to avoid repetitive code for static mesh and skeletal mesh components

You could use UMeshComponent from which both UStaticMeshComponent and USkeletalMeshComponent derive.

TSet<UMeshComponent*> MeshComponents;

if (StaticMeshComponents.Num())
{
    for (UStaticMeshComponent* sm : StaticMeshComponents)
    {
        MeshComponents.Add(sm);
    }
}
else
{
    for (USkeletalMeshComponent* sm : SkeletalMeshComponents)
    {
        MeshComponents.Add(sm);
    }
}

for (UMeshComponent* mc : MeshComponents)
{
	if (UMaterialInterface* DefaultMaterial = mc->GetMaterial(IndexOfMaterialToMakeDynamic))
	{
		DynamicMaterialInstance = UMaterialInstanceDynamic::Create(DefaultMaterial, this);
		mc->SetMaterial(IMaterialDynamic, DynamicMaterialInstance);
	}
}

Runtime DataTable : Import and export game data to and from CSV or Google Sheets while your game is running!

GSheets Operator : Interface with Google Sheets, add new and delete old sheets, edit columns and rows, make in-game spreadsheets and more!

easyCSV : Read data from any CSV and put them in an easy-to-access string map!

iTween : Free, smooth, procedural object animation