List - Pick from index in order row

Asgardesign's Avatar


16 Mar, 2021 10:44 PM

Hello, I'm using nodebox to make some generative graphics. I'm stuck and can't resolve even if I know it's conceptually simple.
I created a .csv with a series of Hex color values in the same column. I need to take a single row using an index to point the exact row. The node I need is a mix of "pick" and "switch", but the "pick" node pick have a random seed and the switch is used for multiple input. Are there any workaround?
Thanks in advance

  1. Support Staff 1 Posted by john on 17 Mar, 2021 01:31 AM

    john's Avatar

    Hi Asgardesign,

    There are several ways to do this.

    If you have a simple list of values and you want to take, say, the 4th item in the list, you can use a slice node. Feed the list into the list port, set start index to the item you want, and set size to 1; that will return the item. When setting the start index remember that counting in NodeBox starts with 0, so to pick the 4th item you should set start index to 3.

    If you have a CSV with multiple columns and you want to pick a particular row based on the value of an index column, use a filter_data node. Feed the table into the data port, set Key to the column you are using to store your indices, set Op to =, and set Value to the value of your index. This will return all rows with an index equal to Value; if your index column has only distinct values (no repeats) this will return a single row.

    Since Filter_data returns entire rows, you will then need to feed the filter_data node into a lookup node to retrieve just your hex value.

    Notice I said that you need to set Key to "the column you are using to store your indices". When you look at a CSV table from NodeBox in Data mode it will show the first column with number indices (0, 1, 2, etc.) labeled "index". But that index column is not an actual column in your CSV and cannot be used as a key when filtering. To filter by index you will need an actual column in your CSV table with ID values you can use to identify each row. You can even call that column "Index" if you want and place numbers (0, 1, 2. etc.) in that column. Or you could call it "color name" and put unique color names in that column that can serve as identifiers to pick a particular hex value.

    If your CSV only has a single column (e.g. "hex") and you don't want to add your own index column, you can just use a lookup node (Set key to "hex" or whatever the column is labeled) on the CSV node. This will return a simple list of hex codes. You can then use the slice node on that list as described above.

    Please let me know if that all makes sense and solves your problem. If not, feel free to reply and attach your CSV; I will make a quick network for you that will return individual hex codes.

    Have fun!


  2. 2 Posted by Asgardesign on 17 Mar, 2021 08:35 AM

    Asgardesign's Avatar

    That's perfect, many thanks :)

  3. Asgardesign closed this discussion on 23 Mar, 2021 10:37 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

15 Jun, 2024 06:14 AM
08 Jun, 2024 09:05 AM
08 Jun, 2024 09:00 AM
04 Jun, 2024 04:37 AM
29 May, 2024 05:15 AM


29 May, 2024 05:12 AM
28 May, 2024 07:37 PM
25 May, 2024 11:52 AM
24 May, 2024 07:39 AM
16 May, 2024 02:11 AM
14 May, 2024 01:29 AM