Hello I'm trying to load data from a row in a .csv file on P5JS and I keep getting the error message Uncaught TypeError: Cannot read property 'arr' of undefined. Does anyone know why I may be getting this? I have check to make sure there is nothing wrong with my .csv file.
您好我正在尝试从P5JS上的.csv文件中的一行加载数据,并且我一直收到错误消息Uncaught TypeError:无法读取未定义的属性'arr'。有谁知道为什么我会得到这个?我检查以确保我的.csv文件没有任何问题。
var table;var travel = [];function preload() { table = loadTable("data/travel.csv", "csv", "header");}function setup() { createCanvas(400,400); textSize(24); travel = table.getRow(1).arr;}function draw(){ background(255); translate(0,height/1); for(var i = 1; i1 个解决方案
#1
0
I ran your script with my own csv file and it worked as expected. So, I suspect the problem is in your file. You should start by trying the same code with a different csv file (grabbed from the internet or wherever).
我用自己的csv文件运行你的脚本,它按预期工作。所以,我怀疑问题出在您的档案中。您应该首先尝试使用不同的csv文件(从互联网或任何地方抓取)相同的代码。
However, I did some searching around and have found a couple of issues noted with load--() P5 functions and the preload() function. If you're still having no luck with this after replacing the csv file, I would try rewriting the script with a callback function rather than using the preload() function. Hope this helps.
但是,我做了一些搜索并发现了一些注意事项,包括load - ()P5函数和preload()函数。如果你在更换csv文件后仍然没有运气,我会尝试使用回调函数而不是使用preload()函数重写脚本。希望这可以帮助。