Thank you so much for all the help! I don't know why I didn't think about needing to be more descriptive for the next person in order for the read through. I will take this all in and use it!
This is all to look through a drop down and get the selected supervisors name and email in order to then write it to a tag so that I can have an alert go off and make an expression rooster in order for a pipeline to send an email to a unique roster.
Also, for people newer to Python ChatGPT can help you re-write nested for/if statements in a more Pythonic way using list comprehension.
It's totally readable, but coming up with things like the list comprehension you see in my script below on my own when I first started with Python would've been very difficult.
def getSensorList():
# get all tags in the analog folder
tags2 = system.tag.browse("[default]Analog_Sensors", {'typeId':'Scaled_Analog_2SP', 'tagType':'udtInstance'}).results
tags4 = system.tag.browse("[default]Analog_Sensors", {'typeId':'Scaled_Analog_4SP', 'tagType':'udtInstance'}).results
tags = tags2 + tags4
# extract tag names and descriptions
names = [str(t['name']) for t in tags]
tag_paths = [str(t['fullPath']) + "/Parameters.Name_SA2SP" for t in tags]
desc = [str(d.value) for d in system.tag.readBlocking(tag_paths)]
# create dataset
headers = ["Description", "Tag Name"]
data = [[desc,name] for desc, name in zip(desc, names)]
dataset = system.dataset.toDataSet(headers, data)
#print headers
#print data
return dataset
It might not get it right the first time. You can try feeding errors back into it, but I've not had much luck with that. ChatGPT is really only useful for simplifying small pieces of code.
I feel like a lot of times it is great to get a baseline if you are lost to where you should even start. Or check your code and find the little mistakes that you made syntax so you aren't just staring at your screen for hours.