I am currently working on creating a JSON file from data in a processed CSV file through an SQL query, and I am performing this task in a notebook in Synapse. Currently, I have the JSON structure functioning, but I encounter a situation where two columns in the CSV contain parameters. I need to retrieve values based on these parameters from another table.
Table1:
Id | data1 | Parameters1 | Parameters2 |
---|---|---|---|
1 | extradata | Example.ValidateData(input1, {MinimumNumber}, {Time}, null) == true | "Example":"(new int[] {Hours.First()/24})" |
2 | extradata | Example.ValidateData(input1, {MinimumNumber}, {Time}, null) == true | "Example":"(new int[] {Hours})" |
Parameters Table:
ParameterName | Value |
---|---|
MinimumNumber | 30 |
Time | 5 |
Hours | 24 |
I would like to replace the values before creating the final JSON file and get an array with the entered values based on the indicated parameter value
New Table:
Id | data1 | Parameters1 | Parameters2 |
---|---|---|---|
1 | extradata | Example.ValidateData(input1, {30}, {5}, null) == true | "Example":"(new int[] {Hours.First()/24})" |
2 | extradata | Example.ValidateData(input1, {30}, {5}, null) == true | "Example":"(new int[] {24})" |
You can use the replacement function below to get a new table in the required format in a Synapse notebook using Python:
Apply the replacement function to the Parameters1 and Parameters2 columns and print it using the code below:
You will get the output as below:
Here is my complete code for reference: