3

thank you for reading my question. I would like to animate a text object in a blender file replacing the body text every 10 frames, iterating row by row through data drawn from a large csv file. There are 2 million rows. The csv data is structured in the following way:

nonce,cost,target,result
1,400,3.12,4
2,400,3.12,3.24
3,400,3.12,1.08
4,400,6.24,3.36
5,400,9.36,33.67

Image shows a screenshot from a blender file which contains the text objects that will be animated By way of an example (using the first 3 rows of my data) I have made this looping animated gif which illustrates in a basic form what I'm trying to achieve. Text that is green/red colour will be replaced every 10 frames with text from the next row in my csv file.

animated gif shows a text object being updated with text data, from the first 3 rows, every 10 frames, drawn from a csv file containing 2 million rows of data.

From my readings here Python seems to be the best way to achieve my animated end goal. There are many excellent answers relating to the use of Python and importing csv data to set the x,y,z location of a mesh or drive a rotation of objects or vertices. Some answers deal with a small amount of changing text data. I cant find an example of how to approach this with text data from such a large data file.

It's entirely possible the solution is obtainable from merging a few answers here, but my python knowledge is not at a level that allows me to make the connections between the expert knowledge given in previous answers.

I'm embarrassed to admit the amount of time I have spent trying to achieve, what seems to be a relatively simple animation. My failure to find a solution has knocked my confidence a little, any guidance is very much appreciated, thank you. I can supply the blend file from my gif animation and a sample of the csv text data if that helps. Thank you very much for your time.

  • sure you want to do it in Blender..? I think it would be like a 200 hours long video, that's more than a week... maybe you want to render just a section of it, or you need something that plays in realtime..? just curious – alambre Mar 29 '22 at 00:34
  • And I wonder why you think python is the best option? I would use animation nodes for such a simple task – Chris Mar 29 '22 at 04:01
  • @alambre lol you are right about that. I plan to adjust the timing down to every 2 frames for 80% of the data. I didnt want to over complicate the question above. The target for the video material need see that every piece of data is there, and be able to check the sequence of events are in the correct order, but they will mostly skip to parts of particular interest. – Amicus Crypto Mar 29 '22 at 04:05
  • @Chris thanks, I'm open to any solution. I may be wrong but any solution I looked at with animation nodes involved adding a python script. I did read one post here where someone had tried something similar with animation nodes but eventually gave up and wrote a python script instead. But I'd be happy to try animation nodes if you think its a good way to approach this. – Amicus Crypto Mar 29 '22 at 04:15

1 Answers1

3

in python you would need to use a handler that updates on frame change, and every n frames read from file and update text object bodies... it's not that complex but 2M lines are a lot of lines to read... here's an answer with nice example of using a handler to update a text object

animation nodes is a great option as Chris stated, I think it can read from text file... but also you can use a little script to import your data as vertices, then even using a handler should be easier and things a lot more stable, as all values are now stored in blend as xyz coordinates -I think first value in your csv was just an index-

here's the script to load data, and a geometry nodes setup you can test, from the imported pointcloud it reads each vertex and writes index and coordinates to text every 10 frames, it's just an example to modify...

blend file

geonodes setup

alambre
  • 1,996
  • 12
  • 13
  • Thanks very much Alambre, I will give this a shot. The first column does look like an index but it's used in part to generate a pseudo random result, the seed is changed at various points in the data and the nonce then resets to 0. Maybe I should break the data up by seed. I think the first seed ran to just half million rows. I wonder how blender will handle big data projects and infinite data streams. – Amicus Crypto Mar 29 '22 at 04:54
  • ok then just coordinates may not be enough... just added a second script to blend to generate some fake data, then tried loading a 2 million rows file with no problem... fixed index offset too... about seeds, that could be a simple list of values, no need to store into vertices – alambre Mar 29 '22 at 05:17
  • @alambre: very nice! +1 for providing a great solution with blend file and even providing building the csv file! – Chris Mar 29 '22 at 05:42
  • @alambre thanks very much for your help, particularly leaving me with enough room to tinker and discover. – Amicus Crypto Mar 29 '22 at 07:19
  • @chris thanks for your support in this thread. If I accept the answer will it close this thread off from updates. I may want to post my final solution. – Amicus Crypto Mar 29 '22 at 07:22
  • no, you should (is my opinion) accept alambres answer but after accepting you can still add your own answer if you want to. – Chris Mar 29 '22 at 07:24
  • ok will do. thanks guys. The original data is online graphed but it has a linear structure. With 2 million rows of data, It's very slow and tedious to navigate through, so hopefully when I finish this it will give wider access to the data. – Amicus Crypto Mar 29 '22 at 07:38
  • great, feel free to ask for any doubts you have with the blend... just checked my 2M lines text file together with batfinger's code on that answer I linked, it worked fine here... but you would need to modify the script to read a line and update different text objects in scene – alambre Mar 29 '22 at 23:01
  • @alambre your solution is quite ingenious, creating a point cloud in order to borrow the xyz location co-ordinates and use that to store the csv data. I really laughed when I saw the point cloud. What strikes me about that is, it is a kind of work around solution to achieve an outcome that Blender doesn't really facilitate. I mean would you say thats the standard way to pull large data from a csv file and iterate through it row by row? – Amicus Crypto Apr 01 '22 at 22:10
  • @chris I'm kind of curious how you would have addressed this in animation nodes. I'd like to experiment a little with that to inform my own understanding of what's possible. Perhaps you have seen a good example here that I could pick apart. If you know of any example, that would be great. Thanks. – Amicus Crypto Apr 02 '22 at 00:53
  • 1
    Ask a new question how to do it with animation nodes and I will show you – Chris Apr 02 '22 at 02:24
  • I imagined that 2 millions lines could be a problem, vertices on the other side is native data for Blender, and you had 3 data columns, that's all... but python handlers worked for me too, even with that volume of data: check this file, paste your own data and run script to activate the handler, don't know how stable it would be on render... btw I still don't think a video is the best solution here but you know better – alambre Apr 02 '22 at 02:36
  • @alambre, Id like to explain to you precisely what I'm trying to do, but I cant do that in a public forum as it will always attract the kind of attention I don't want. – Amicus Crypto Apr 02 '22 at 11:34
  • @Chris good idea... I better search the other questions first or get creative with how I ask it. – Amicus Crypto Apr 02 '22 at 11:39