Lots of conflicting info on creating node materials and at wits end!

Hi there, hopefully this is a simple question?

I’m reading out Photoshop ACT (Palette files) to a CSV, to then render spacially in Blender.

It’s working fine for viewport rendering, but I was hoping to be able to programatically create a series of Prinipled BSDF shaders with a little emission etc.

All the commented out code is trying to create a material as a reference / object with a specific name ( or not) - either way, it says the object is null , I can’t set a name , or am missing a name.

Right click to view a bigger version of image.

For some extra context- I’d ideally like to be able to replicate the below ( I can do it manually with nodes, where one material is applied to all instances, and the colour part is taken from the object data )