# Grid variable help (python)

**URL:** <https://matillioncommunity.discourse.group/t/grid-variable-help-python/1824>\
**Category:** Matillion ETL\
**Created:** [July 18, 2022, 6:41am UTC](https://matillioncommunity.discourse.group/t/grid-variable-help-python/1824 "2022-07-18T06:41:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SB699925](https://sea2.discourse-cdn.com/flex002/user_avatar/matillioncommunity.discourse.group/sb699925/32/1180_2.png) [@SB699925](https://matillioncommunity.discourse.group/u/SB699925)\
**Post date:** [July 18, 2022, 6:41am UTC](https://matillioncommunity.discourse.group/t/grid-variable-help-python/1824/1 "2022-07-18T06:41:12Z")

</div>

Is there detailed documentation anywhere on Grid variables? How they are structured and how they should be manipulated in python?

&nbsp;

I'm not a python expert and maybe that's my problem.

&nbsp;

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.

&nbsp;

For example, the first 3 lines of the response data looks like this:

&nbsp;

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,

&nbsp;

When I dump this into a grid variable in python, I want it to have 3 rows with 33 columns.

&nbsp;

How can I add these column/rows into a grid variable? Here is my current script:

&nbsp;

&nbsp;linecount = 0

&nbsp;for row in data:

&nbsp;#print (row)

&nbsp;#print (row.split(',')[0])

&nbsp;if linecount == 0:

&nbsp;&nbsp;&nbsp;header\_cols = row.split(',')

&nbsp;&nbsp;&nbsp;for col in header\_cols:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gv.append([col,'VARCHAR'])

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#gv\_data.append([col])

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#print (col)

&nbsp;&nbsp;&nbsp;#print (len(gv))

&nbsp;&nbsp;&nbsp;#context.updateGridVariable('order\_mate\_data', gv\_data)

&nbsp;&nbsp;&nbsp;#print (len(gv\_data))

&nbsp;if linecount != 0 and row.split(',')[0] != '':

&nbsp;&nbsp;&nbsp;g = []

&nbsp;&nbsp;&nbsp;data\_cols = row.split(',')

&nbsp;&nbsp;&nbsp;#print (data\_cols)

&nbsp;&nbsp;&nbsp;#for col in data\_cols:

&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;g.append(col)

&nbsp;&nbsp;&nbsp;#gv\_data.append(g)

&nbsp;&nbsp;&nbsp;for col in data\_cols:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g.append(col)

&nbsp;&nbsp;&nbsp;gv\_data.append(g)

&nbsp;&nbsp;&nbsp;#gv\_data.append([row])

&nbsp;linecount += 1&nbsp;&nbsp;

&nbsp;print (gv)

&nbsp;print (gv\_data)

&nbsp;

But it currently returns this error:

&nbsp;

The number of elements [33] exceeds the number of defined columns [1] for grid variable.

&nbsp;

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.

&nbsp;

Thanks
