Get data from Grasshopper to Excel

Hi there,
I am trying to create a table in Excel using Grasshopper data.
I was reading the documentation and you say it is better to work with lists (which is what i need) and the example you show using Dynamo is quite clear an simple but in Grasshopper if you want to create a list of lists, automatically we have a tree, which is not anymore list of lists but an object, and the result in excel is getting the tree paths as headers besides the fact that the structure is lost.
This is my data
image
This is what i get on Excel

I can use python to create a list of lists but I am training a group of colleagues and they don’t use python.
The alternative is to download list by list but this in not efficient with a big dataset.

1 Like

@GabrielGarcia The data headers can draw from object properties/parameters:

This creates a Custom Speckle Object within which you then select on Read within Excel. Here I’m selecting the first object:

Each property list can be received separately if you need, but this matches your describe use case.

excel-test.gh (8.7 KB)

1 Like

@jonathon Thank you for the solution provided. Your example file works okay, i made a similar test and a column is missing. I will figure out what went wrong.
The only annoying thing is to write the headers manually. If I have 20 columns, it will be painful to do all work that manually (besides removing manually the detach property (@) to every added layer.

2 Likes

Hi @GabrielGarcia!

Thanks for bringing this up! I guess this was an undetected result of our latest change in GH from List of Lists to Tree objects. While we come up with a workaround for this, I agree that setting this up manually in a CSO component will be a pain… if you’re just dealing with “simple objects” you can use the Create Speckle Object by Key/Value to automatically create these objects from a list of property names and values. I think you’ll find this useful, although for complex scenarios is a bit weird to use.

For more complex dynamic object creation, I’d generally recommend using a python or c# script, which we have documented on our docs :wink:

When adding data to an object in a script, you don’t even need to deal with conversions (i.e. just shove the points you need in a property) and the sender will take care of converting everything “to speckle” before sending.

1 Like

Thanks @AlanRynne, for now I will use the Create Speckle Object by Key/Value.
I know that using python or c# would be the most useful for now but in this case, I am training a group of people to use Speckle and they have no knowledge about programming languages so I needed a built-in solution to this issue.
Anyways, this will work for now, thanks!

2 Likes

Hi @jonathon,

Do you know if it possible to use this method with lists of different lengths?
I’m getting a result where the last item in the list is repeated.

Thanks


Hi @MatthewF

This is Grasshopper standard behaviour, when it runs out of items in a list (but still has more in other inputs), it will repeat the last item in the list as many times as the longest list in the entire input.

This is done by Grasshopper before passing in the inputs to the component, so there is no way for us to distinguish between values that were provided by you and values that are repeated automatically by Grasshopper.

There are ways to affect the Data Matching, but none do exactly what you’d want as far as I’m aware.

In essence, what is happening is that GH will do longest list on the inputs that have shorter length, repeating the “last” item it found.

Solution

The ideal way to deal with this is either to provide null or empty values on the inputs that need it so that your object inputs match in length.

2 Likes

Hi @AlanRynne

Ah yeah, that makes sense.
Thanks a lot.

3 Likes