# Get column headers

**URL:** <https://forum.inductiveautomation.com/t/get-column-headers/1048>\
**Category:** Archived Topics\
**Created:** [March 23, 2009, 4:24pm UTC](https://forum.inductiveautomation.com/t/get-column-headers/1048 "2009-03-23T16:24:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [March 23, 2009, 4:24pm UTC](https://forum.inductiveautomation.com/t/get-column-headers/1048/1 "2009-03-23T16:24:29Z")

</div>

is there a way in the python scripting language to get the names of the headings on a table? In order to change a python dataset to a component dataset i need the headers. instead of hard coding the headers into a list i thought getting a list returned from a table component would be better.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [March 23, 2009, 5:05pm UTC](https://forum.inductiveautomation.com/t/get-column-headers/1048/2 "2009-03-23T17:05:10Z")

</div>

Here, something like this should help:

`existingData = event.source.parent.getComponent("Table").data
headers = [existingData.getColumnName(c) for c in range(existingData.getColumnCount())]`

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [March 23, 2009, 8:56pm UTC](https://forum.inductiveautomation.com/t/get-column-headers/1048/3 "2009-03-23T20:56:57Z")

</div>

it works great thanks.

the second line of your code has a weird syntax that i was unaware of. you are doing about 3 things all at one time. i would have written the line like this:

```auto
headers = []
for c in range(existingData.getColumnCount()):
    headers.append(existingData.getColumnName(c))
```

it is strange how your code gets the column name before the for loop.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [March 23, 2009, 9:27pm UTC](https://forum.inductiveautomation.com/t/get-column-headers/1048/4 "2009-03-23T21:27:00Z")

</div>

Nifty, huh? Its my favorite Python language feature: [list comprehensions.](http://docs.python.org/tutorial/datastructures.html#list-comprehensions)
