Drawing a radar with CSV file reading error

Hi!

Nowadays I’m trying to draw radar with csv file. csv file format is like

(date, x, y)

example :

181743,78,152
181744,123,512
181745,126,341
181746,153,153
181747,173,175

and so on

This is my code

float a;
float b;
float c;
float d;
float time;

import processing.serial.*;
void setup() {
size(800,500);
frameRate(0.5);
Table table = loadTable(“example.cvs”, “header”);
TableRow t = table.getRow(0);
TableRow pre = table.getRow(1);
TableRow now = table.getRow(2);
float time = t.getFloat(0);
float a = pre.getFloat(1);
float b = pre.getFloat(2);
float c = now.getFloat(1);
float d = now.getFloat(2);
println(a);
println©;

}

void draw() {
translate(width/2, height/2);
drawradar();
drawtarget();
}

void drawtarget() {
ellipse(a, b, 100, 100);
ellipse(c, d, 100, 100);
line(a,b,c,d);
println(time);

}

void drawradar() {
background(0);
noFill();
strokeWeight(2);
stroke(98, 245, 31);
ellipse(0, 0, 900, 900);
ellipse(0, 0, 700, 700);
ellipse(0, 0, 500, 500);
ellipse(0, 0, 300, 300);
ellipse(0, 0, 100, 100);
strokeWeight(1);
line(-400, -400, 400, 400);
line(400, -400, -400, 400);
line(0, -400, 0, 400);
line(-400, 0, 400, 0);
textAlign(RIGHT);
text(“10cm”, 50, 0);
text(“20cm”, 150, 0);
text(“30cm”, 250, 0);
text(“40cm”, 350, 0);
text(“50cm”, 450, 0);
}

This is my error

NullpointerException

While I am working with my project and I thought it has no problem, but I encountered some error.
Please give me some advice to solve this problem…

csv should be seperated by ; instead of ,
I didn’t look further but that might be a problem.

When it comes to NullPointer Exceptions, that’s exactly what it is: a null pointer exception. That means that your code is trying to look for something, that in essence, doesn’t really exist. The only main place that you’re loading in a file is in the line that says:

Table table = loadTable(“example.cvs”, “header”);

It says “example.cvs” don’t you mean “example.csv”?

That’s first. And maybe if it still doesn’t work, you can try adding in the full path to that file?

There could be something else causing this, but I highly doubt it. Hopefully this helps,

EnhancedLoop7