x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Is there a better way to loop through all elements of a datatable?

So after much experimentation, I found that I was unable to import a datatable from a CSV file and then use Blueprints to loop through all the elements that were read in through the table. This is because UnrealEngine provides the useful GetDataTableRow node, but I found that I was completely unable to use a ForEach loop node to get all the rows from the table. I WAS able to create a regular ForLoop node and iterate, but only if I hard coded in the number of elements into the loop, since currently there seems to be no way to query the DataTable for its total number of rows?.

I searched the forums for a while and found no information about how to do this.

After considering my dilemma for a bit, I invented the following way to successfully read in all rows of any DataTable read in from a CSV datatable node. However, it would be nice if say, there was a DataTable node called: GetNumDataTableRows that would return the total number of elements in the table - but that doesn't exist afaik.

Anyway, I show how to create your own WhileLoop which can easily get the results you need to read in all rows of the DataTable. I hope this helps anyone else out there who ran into the same issue as me. And by all means, if someone has a better way, please post! :P

alt text

[1]: /storage/temp/27099-screen+shot+2015-01-18+at+9.43.19+pm.png

Product Version: Not Selected
Tags:
more ▼

asked Jan 19 '15 at 05:38 AM in Blueprint Scripting

avatar image

Silverleaf1
173 8 68 28

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

The ForEach node operates on arrays. DataTables are maps, not arrays, so that node won't immediately work there.

more ▼

answered Jan 19 '15 at 05:04 PM

avatar image

joeGraf STAFF
1.5k 35 12 69

avatar image Silverleaf1 Jan 19 '15 at 07:18 PM

Of course in C++, you can still use iterators to loop through std::map elements, so maybe we'd either need to alter the ForEach node to also accept maps in additions to arrays, or we could add a DataTable node that gets the table as an array.

The use case here is: I have a DataTable with an unknown number of elements coming in from the CSV file (and can change at any time), and then I'd like to populate a ScrollBox with all the elements to show them in a UI.

The way I set it up above works just fine for those purposes, but it's less elegant than having some dedicated node functionality to handle iterating through.

avatar image joeGraf STAFF Jan 19 '15 at 07:41 PM

STL is not used by any version of the engine. We do have our own iterators, though, so you could use those to implement the node you describe

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

alt text

more ▼

answered Jul 25 '15 at 11:11 AM

avatar image

paemato
76 1 72 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hi First, thanks for your post. I was running into a similar problem with needing to read an element from every row.

I have made a modification to your graph for my own use. Instead of requiring the row name to be a variation of an INT, I have added a new column in my CSV labelled "Next row". This is the name of the row following it. This is read from the row in each iteration and updates the row name to read next. The final one is filled with END. A String!= for the while loop check is done with each row.

I have also set the while loop "row not found" to break the loop; incase I forget to add the END when updating the table.

more ▼

answered Feb 13 '15 at 12:18 PM

avatar image

Dict8
1 1 1 3

avatar image joeGraf STAFF Feb 13 '15 at 03:23 PM

Nice. That's a decent solution. When I can find some time, I want to write a way to treat it as an array for automatic ForEach style support

avatar image FrederickD Apr 01 '18 at 07:12 PM

Hi Joe,

Iterators for map still not supported in blueprint... These seem like very basic nodes to have ?

avatar image joeGraf STAFF Apr 02 '18 at 03:30 PM

I've added the owner of Blueprints so he can weigh in on this

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question