Is there detailed documentation anywhere on Grid variables? How they are structured and how they should be manipulated in python?
I'm not a python expert and maybe that's my problem.
I have a grid variable with 1 "dummy" column. I want to read a list of comma-separated values (from an API) through python and pass these values into the grid variable.
For example, the first 3 lines of the response data looks like this:
69,1365,66966,78444,2022-07-14 20:18:51.0,2022-07-14,20:18:51,2022-07-14,0E-8,0E-8,0E-8,0E-8,0E-8,CASH,Cash,TABLE,CD1,,14003,7,,,1,,1,,176,"CHEZ ",Manager,,,Day,
69,1365,66975,78416,2022-07-14 17:24:53.0,2022-07-14,17:24:53,2022-07-14,65.50000000,65.50000000,0E-8,0E-8,0E-8,CREDIT,Visa,TABLE,CD1,,15196,7,,,1,,1,,188,"SARA ",Manager,,,Day,
69,1365,66976,78432,2022-07-14 18:26:09.0,2022-07-14,18:26:09,2022-07-14,97.00000000,97.00000000,0E-8,0E-8,0E-8,CREDIT,Visa,TABLE,CD1,,15213,7,,,1,,1,,176,"CHEZ ",Manager,,,Day,
When I dump this into a grid variable in python, I want it to have 3 rows with 33 columns.
How can I add these column/rows into a grid variable? Here is my current script:
linecount = 0
for row in data:
#print (row)
#print (row.split(',')[0])
if linecount == 0:
header_cols = row.split(',')
for col in header_cols:
gv.append([col,'VARCHAR'])
#gv_data.append([col])
#print (col)
#print (len(gv))
#context.updateGridVariable('order_mate_data', gv_data)
#print (len(gv_data))
if linecount != 0 and row.split(',')[0] != '':
g = []
data_cols = row.split(',')
#print (data_cols)
#for col in data_cols:
# g.append(col)
#gv_data.append(g)
for col in data_cols:
g.append(col)
gv_data.append(g)
#gv_data.append([row])
linecount += 1
print (gv)
print (gv_data)
But it currently returns this error:
The number of elements [33] exceeds the number of defined columns [1] for grid variable.
I am just not sure what the structure of the grid variable should look like and if I can dynamically add columns which is what I'm trying to do.
Thanks