2

Using python, how can I update a text object in a blender animation, every 10 frames, using data from a csv file containing 8million data points?

This question was addressed nicely by alambre using python (as requested). @chris proposed an Animation nodes solution but didn't get the opportunity to elaborate.

I'm curious to know what an animation nodes solution would look like to the same problem. I'd hope to try both solutions and weigh up the pros and cons in the context of my own production workflow. Thanks for reading my question and for your time.

1 Answers1

3

node setup:

enter image description here

read data - python script:

import csv

data = []

with open('/Users/chris/downloads/nueva_data.csv') as f: reader = csv.reader(f) for row in reader: data.append(row)

result:

enter image description here

Note: i am using a Macbook so your file path string might look different.


Update:

unfortunately with the upper version and with 8 Mio data entries it feels like waiting endless for a result. So this version just reads one time on frame 1:

enter image description here

Chris
  • 59,454
  • 6
  • 30
  • 84
  • that actually looks not too complicated at all. Does it load in all the data first or does it stream the data from the file as needed? – Amicus Crypto Apr 03 '22 at 11:51
  • thanks man, that is quite a simple set up! so to pull in the other data Id just add a get list element for each value that I want to display. – Amicus Crypto Apr 03 '22 at 11:56
  • worse - it reads it every frame....we should improve that – Chris Apr 03 '22 at 11:56
  • i am working on a better solution...give me some minutes ;) – Chris Apr 03 '22 at 11:59
  • lol take your time please. For my own purposes I only need one row of data at any one time and that will be in sequence. Maybe could load the row based on the frame number or load the next hundred values every hundred frames.. – Amicus Crypto Apr 03 '22 at 12:24
  • updated my answer – Chris Apr 03 '22 at 12:26
  • yeah, you are right....reading in chunks would be a better solution – Chris Apr 03 '22 at 12:26
  • but this is then more a python than a animation nodes question ;) – Chris Apr 03 '22 at 12:27
  • 1
    I assumed Animation nodes writes Python behind the curtain. This is very helpful either way, as I plan to add in some updating stats as blender moves through the csv content. Value Frequency, probability vs actual occurrence. Highest values, a rolling median result. I think AN might be useful for that also. – Amicus Crypto Apr 05 '22 at 05:38
  • AN is useful anyway!!! It is an AMAZING tool and by allowing any python code in between (script node) possibilities are endless. Unfortunately this isn't possible with GN, Shader nodes etc. It is such a great power....!!! – Chris Apr 05 '22 at 05:57