Hello @Jered Willoughby,
Welcome to the MS Q&A platform.
You can use the json.loads() method to convert the string into a list. Here is an example:
import json
schema_array = "[('creationdate','timestamp'),('agent_name_txt','string'),('email','string'),('agent_hire_date','date'),('days_since_hire_text','int'),('department_auto','string')]"
# Convert the string into a list
schema_list = json.loads(schema_array)
# Print the data type of the list
print(type(schema_list))
This should output <class 'list'>, indicating that the string has been successfully converted into a list. You can then use the list in your Databricks notebook as needed.
Alternatively, you can use the ast.literal_eval() method to convert the string into a list. This method is safer than json.loads() because it only evaluates literals and not arbitrary code. Here is an example:
import ast
schema_array = "[('creationdate','timestamp'),('agent_name_txt','string'),('email','string'),('agent_hire_date','date'),('days_since_hire_text','int'),('department_auto','string')]"
# Convert the string into a list
schema_list = ast.literal_eval(schema_array)
# Print the data type of the list
print(type(schema_list))
This should also output <class 'list'>, indicating that the string has been successfully converted into a list. You can then use the list in your Databricks notebook as needed.
I hope this helps. Let me know if you have any other questions.