Trying to set text component of a GameObject as it is instantiated

I am currently trying to create a function that works with a StreamReader to read a line of text, parse the text, and then instantiate a text variable prefab to immediately assign that text for each line within the text file.

I want to use the values that are split into the temps[ ] array as the values assigned to the text prefabs.
I don’t know how to assign these values and any help or ideas would be greatly appreciated.

Edit: The text input lines look something like this:
Coke,24.99,16
Sprite,23.99,18

 public void displayTable()
    {
        // temp variables
        string[] temps;

        // count lines
        var enumLines = File.ReadLines(saveDataPath, Encoding.UTF8);
        // have reader read the lines within save file
        try
        {
            // instantiate reader
            using (StreamReader sr = new StreamReader(saveDataPath))
            {
                // iterate over lines
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    // parse lines into variables
                    foreach(var lines in enumLines)
                    {
                        Debug.Log(lines);
                        temps = lines.Split(',');
                        // duplicate objects for use in table
                        Instantiate(pfItem, new Vector3(0, 0, 0), Quaternion.identity);
                        Instantiate(pfOrderCost, new Vector3(0, 0, 0), Quaternion.identity);
                        Instantiate(pfOrderQuant, new Vector3(0, 0, 0), Quaternion.identity);
                    }
                }
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("The file could not be read:");
            Console.WriteLine(e.Message);
        }
    }

GameObjects can only have a .name field, which is only visible in inspector.

If you’re seeing something onscreen, it is NOT going to be the .name field.

If you’re seeing something onscreen, it is likely a UI thing, such as a TextMeshProUGUI for instance.

Those are just Components. You need a reference to them, then go review the documentation for the name of the field you want, usually just .text in most cases.

Otherwise, start with tutorials for how to use the UI components or else your chances of success in this endeavor are almost zero. It’s a large complicated system that needs to be grasped in an orderly fashion.

Please use the Scripting forum for general scripting posts and not the 2D forum which is for 2D specific posts.

I’ll move your post.

Thanks.