Append items to a list of lists

I thought that was really a simple procedure but I couldn’t find a solution here in the forum.
All I want to do is to be able to vary a slider, do some calculations, get a list of values and append it to a “main” list of lists (Which would be initially empty). Then whenever I change the intial values, some calculations will take place, and the output list of values should be appended to the main list. At the end, the list should be copied to a csv file.

A very simple script is attached where i want to vary a step of a sequence, and then add it to a list of sequences, and then re-vary the step and add the new one to a main list that keeps track of every generated sequence and so on.

1 Like

Don’t you need List.Join or List.Create nodes?
If not, please take a look here:
http://dynamoprimer.com/en/06_Designing-with-Lists/6-2_working-with-lists.html
http://dictionary.dynamobim.com/#/

Hi,
These operations are for a predetermined number of lists in a list. What I want to do is to be able to do this indefinitely.
It should function as the append method in python for example. It should recursively add a new list to an existing list of lists after varying the initial parameters.

I would try List.Cycle then

Your problem requires recursion since it depends on the previous state to generate the current/new state. This is visual programmings Achilles heel unfortunately! You could try writing the data to a txt file after processing, retrieve it for the next run, perform List.Join to achieve the desired result then write to Excel.

Couldn’t you just copy and paste your nodes each time you want to rerun, and add the result to a List.Join or List.Create?

Hi Thomas,
I thought of something similar. But when I try to do that and read from the CSV file I wrote the data to, I get this message
"Warning: One or more of the input types are not matching. Couldn’t find a version of ReadFromFile that takes arguments of type (string)"

Hi Yna,
I can, but the aim was to automate the process to get a list of results to visualize.

Is there just a python node to append the new set of values?
Something like:
mainlist = []
For i in counter:
mainlist.append([newsublist])

Hi @Mekawy ,
yes but you’d have to store the previous data somewhere… here’s one way you could achieve what you want, using an excell sheet to store the data and visual programming :


the trick here is to read the number of columns in the file and use it to set the column to write on .

3 Likes

@Mekawy - I am curious about what task you are trying to accomplish. What context do you need this functionality in? The reason I ask is because we are working on designing/prototyping looping nodes for Dynamo and am trying to figure out use cases. Your problem seems to be a good one. Can you clarify why you are trying to accomplish this? In what workflow/context?

Also, you can use Imperative nodes to do recursion…Hope that helps. Let me know if this is what you were looking for.

5 Likes

Hi Mostafa,
Thank you for the detailed solution. However, I can’t seem to understand the logic you implemented behind “start row” and “start column”. Dynamo throws an error when I do exactly as you did.

Hi Racel,
This looks good, with the exception that I need the final list to be nested. The reason being that I want to use the output to produce charts based on some analytics made on the design scheme. So I need distinct “records” of each design variation to be fed in a stacked bar chart for example.

what error do you get?
Did you make sure the lacing of list.count was set to longest? :

the logic is that list count gets the number of colums containing data in the excel file.That information helps specify which column to write the next list of numbers.

ok @Mekawy - Try this. Thanks for the additional info. If you get it working, would you mind sending the final graph/results my way? Just PM me here…

4 Likes

@Mekawy- Interestingly, have you ever used presets? We were just talking about these today. They might be useful to you as you are looking at design variations…

Thanks Mostafa. That worked !

1 Like

Thanks Racel. That worked like a charm!
If I reached something solid, I’ll let you know. As for presets, I’ll also take a look at them.

Query
How I Append “List-01”, based on Values of “List-02” by Dynamo? Please reply Any One.