# Export parameters list to EXCEL -Convert 2nd level list to string for Excel export

**URL:** <https://forum.dynamobim.com/t/export-parameters-list-to-excel-convert-2nd-level-list-to-string-for-excel-export/78888>\
**Category:** Revit\
**Tags:** revit, clockwork, excel, python, dynamo\
**Created:** [July 20, 2022, 6:57pm UTC](https://forum.dynamobim.com/t/export-parameters-list-to-excel-convert-2nd-level-list-to-string-for-excel-export/78888 "2022-07-20T18:57:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ron\_Allen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ron_allen/32/124849_2.png) [@Ron\_Allen](https://forum.dynamobim.com/u/Ron_Allen)\
**Post date:** [July 20, 2022, 6:57pm UTC](https://forum.dynamobim.com/t/export-parameters-list-to-excel-convert-2nd-level-list-to-string-for-excel-export/78888/1 "2022-07-20T18:57:09Z")

</div>

Always get brain damage coming back into Dynamo and Python. 🧱  
Using the clockwork node, I extract all the parameter names, categories, parameter groups, parameter type, is visible, parameter element and is instance information for every parameter.

I am trying to convert the associated “Categories” to a string of comma separated values for import to Excel, so the columns remain aligned - otherwise on export the categories break the columnar formatting. I only want to convert the 2nd level list where there are multiple items and return the string as a single itme in the list so as not to break the excel export. VBA’d in excel in 15 minutes to merge, but want this in Dynamo/PY - and I know its possible

The array to string converts all the elements from the upper and lower lists into one big string. No way to have it just convert the @l2 which is what I am after.

attempted a python but cannot get the Names of the Categories:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/e/4e818e4069e7eb185e0cc45dc1bd4a8862fb8fd4.png)

```auto
# Load the Python Standard and DesignScript Libraries
import clr
import sys
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

# The inputs to this node will be stored as a list in the IN variables.
myList = UnwrapElement(IN)

for i in myLists:
    j=','.join(Category.Name(x) + ',' for x in UnwrapElement(i))
OUT = j ##Dumb output for now- want to sub the string for the list
                ##of the sublist in Mylist[*][HERE]
                ##so Mylist[*][0]= join(every element in Mylist[*][*]

```

DYN attached - areas in RED is the issue.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/9/19266e0b9d2fe74763a5121312d4595f15cb4cb3.jpeg)

Would like to understand how to replace a 2nd level list of elements with a single item list of the concatenated string… to export to get this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/a/2a2d8784099ffab30c0bbb1d6687207e9fc6b47c.png)  
[Export\_parameters.dyn](https://forum.dynamobim.com/uploads/short-url/buHvKDaGlSRxJbVd4DY5QB5yll1.dyn) (52.1 KB)

Thanks!  
Ron

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [July 20, 2022, 11:20pm UTC](https://forum.dynamobim.com/t/export-parameters-list-to-excel-convert-2nd-level-list-to-string-for-excel-export/78888/2 "2022-07-20T23:20:22Z")

</div>

> [@Ron\_Allen](#):
>
> Would like to understand how to replace a 2nd level list of elements with a single item list of the concatenated string

The .Join function of Python’s string class is a good place to start; it will take a list of strings and convert it to a single string the initial string as the separator. Something like this (don’t have Python available as I finish recovering from COVID, so you may need to edit):

```auto
listOfStrings = [“Thing A”, “Thing B”, “Thing 1”, “Thing 2”]
joinedStrings = “, “.join(listOfStrings”
OUT = joinedStrings

```

---

<div class="post-metadata">

**Author:** ![Ron\_Allen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ron_allen/32/124849_2.png) [@Ron\_Allen](https://forum.dynamobim.com/u/Ron_Allen)\
**Post date:** [July 20, 2022, 11:43pm UTC](https://forum.dynamobim.com/t/export-parameters-list-to-excel-convert-2nd-level-list-to-string-for-excel-export/78888/3 "2022-07-20T23:43:13Z")

</div>

I want to "roll up " at this 2nd level…  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/f/7f83777f3d4821e5d6c984f2f12285ceee046cef.png)  
getting the names of the classes in python has proven to be challenging as well. Tried variations on the syntax- and unwrapelements() but no joy : (

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [July 21, 2022, 1:05am UTC](https://forum.dynamobim.com/t/export-parameters-list-to-excel-convert-2nd-level-list-to-string-for-excel-export/78888/4 "2022-07-21T01:05:11Z")

</div>

Assuming those are strings, unwrapping isn’t the issue - Dynamo’s Python integration will treat the two data types the same. The only time you need to unwrap is when you convert from a Dynamo interpretation of a .net object to a native .net object (ie: a Dynamo reference to a Revit wall to a native Revit Wall). Dynamo \> Python should happen automatically for standard data types.

Since you have a list of lists you’ll want to add a for loop or utilize list comprehension to achieve the result.

This runs fine in an online Python environment, so assuming you have a list structure which matches this you should be all set. If it’s a different list structure you’ll have to alter the setup accordingly.

```auto
myListOfLists = [["Thing 1", "Thing 2", "Thing 3"], ["Thing A", "Thing B", "Thing C"] ]
#For Loop Example
forLoopResults = []
for myList in myListOfLists:
    forLoopResults.append( ", ".join(myList) )

#List Comprehension Example
listComprehensionResults = [", ".join(myList) for myList in myListOfLists]

#return both results to the Dynamo environment
OUT = forLoopResults, listComprehensionResults

```

---

<div class="post-metadata">

**Author:** ![Hamish](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@Hamish](https://forum.dynamobim.com/u/Hamish)\
**Post date:** [July 21, 2022, 4:57am UTC](https://forum.dynamobim.com/t/export-parameters-list-to-excel-convert-2nd-level-list-to-string-for-excel-export/78888/5 "2022-07-21T04:57:01Z")

</div>

> The array to string converts all the elements from the upper and lower lists into one big string. No way to have it just convert the @l2 which is what I am after.

Assuming I’ve understood correctly, then String.Join will do what you’re after:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/a/1ad3651c6872030f80ec7660eebabbadba1be8e0.png)

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [July 21, 2022, 8:18pm UTC](https://forum.dynamobim.com/t/export-parameters-list-to-excel-convert-2nd-level-list-to-string-for-excel-export/78888/6 "2022-07-21T20:18:03Z")

</div>

Hello,

> [@Ron\_Allen](#):
>
> attempted a python but cannot get the Names of the Categories:

there is a small error

try this

```auto
import sys
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

myList_with_sublst = UnwrapElement(IN[0])
OUT = []

for sublst in myList_with_sublst:
    j =','.join(x.Category.Name for x in sublst)
    OUT.append(j)

```

---

<div class="post-metadata">

**Author:** ![Ron\_Allen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ron_allen/32/124849_2.png) [@Ron\_Allen](https://forum.dynamobim.com/u/Ron_Allen)\
**Post date:** [August 10, 2022, 2:56pm UTC](https://forum.dynamobim.com/t/export-parameters-list-to-excel-convert-2nd-level-list-to-string-for-excel-export/78888/7 "2022-08-10T14:56:11Z")

</div>

@Hamish , nope, that is the problem. I want to maintain the list structure @L1 but turn ead @L2 sublist into a string for export of parameters : )
