p.preload = () => {
data = (p as any).loadTable("http://127.0.0.1:3448/sample.csv", "csv", "header");
};
I would like to intiliaze the data above from a js response object. The object has the same csv content.
My question is how to initialize a p5 table from an object consisting of csv content as string.
Well, that’s what happens behind the scenes anyway. If there was a p5.js function to which you could pass CSV content as a string, that function would still have to break the string apart and build a p5.Table from those parts. It wouldn’t be a less expensive operation just because another programmer implemented the function for you.
I wouldn’t worry too much before you actually try it, though. Maybe it will go faster then you expect, and you only have to do it once at the beginning of your sketch, during setup.
Just because I’m curious, what’s the reason you can’t have the CSV in a file and use the built-in loadTable function?
and you to get the csv file from url, type less-xy.csv.
In short, what i am trying to accomplish in that code sandbox is, fetch a csv file using swagger and then display its content using p5-js. As you can see in the code, right now, i have hard coded the url in p5.js, so we are actually fetch file twice, once from swagger and one done by p.preload…I want to load the data dynamically in p5.js.