# Converting fpmi.gui.getWindowNames() to dataset

**URL:** <https://forum.inductiveautomation.com/t/converting-fpmi-gui-getwindownames-to-dataset/1809>\
**Category:** Archived Topics\
**Created:** [May 5, 2010, 10:09pm UTC](https://forum.inductiveautomation.com/t/converting-fpmi-gui-getwindownames-to-dataset/1809 "2010-05-05T22:09:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimE](https://avatars.discourse-cdn.com/v4/letter/t/ee59a6/32.png) [@TimE](https://forum.inductiveautomation.com/u/TimE)\
**Post date:** [May 5, 2010, 10:09pm UTC](https://forum.inductiveautomation.com/t/converting-fpmi-gui-getwindownames-to-dataset/1809/1 "2010-05-05T22:09:14Z")

</div>

I want to put the results from fpmi.gui.getWindowNames() into a list. I made serveral incorrect attempts at trying to do this but I am still having difficulty figuring it out. I read through the old and new manuals but I still have a mental block.

How do you take the return list of strings and convert it to a dataset?

Thanks,

---

<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:** [May 5, 2010, 11:25pm UTC](https://forum.inductiveautomation.com/t/converting-fpmi-gui-getwindownames-to-dataset/1809/2 "2010-05-05T23:25:28Z")

</div>

`names = fpmi.gui.getWindowNames()
rows = [[wname] for wname in names]
dataset = fpmi.dataset.toDataSet(["Windows"], rows)`

---

<div class="post-metadata">

**Author:** ![TimE](https://avatars.discourse-cdn.com/v4/letter/t/ee59a6/32.png) [@TimE](https://forum.inductiveautomation.com/u/TimE)\
**Post date:** [May 6, 2010, 2:22pm UTC](https://forum.inductiveautomation.com/t/converting-fpmi-gui-getwindownames-to-dataset/1809/3 "2010-05-06T14:22:57Z")

</div>

Just what I needed. I’m glad I never posted what I was trying. You just replaced a half page of code with one line. Sooner or later I will get the hang of this.  
Thank you,

---

<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:** [May 6, 2010, 3:27pm UTC](https://forum.inductiveautomation.com/t/converting-fpmi-gui-getwindownames-to-dataset/1809/4 "2010-05-06T15:27:52Z")

</div>

Yeah that middle line is a list comprehension. It is the equivalent of doing this:

`names = fpmi.gui.getWindowNames()
rows = []
for wname in names:
   rows.append([wname])
dataset = fpmi.dataset.toDataSet(["Windows"], rows)`

List comprehensions are a little much for most beginners, but once you get the hang of them, they sure are efficient (to write).
