# Csv does not exist or could not be read NullPointerException

**URL:** https://discourse.processing.org/t/csv-does-not-exist-or-could-not-be-read-nullpointerexception/10785
**Category:** Coding Questions
**Created:** [April 29, 2019, 4:36pm UTC](https://discourse.processing.org/t/csv-does-not-exist-or-could-not-be-read-nullpointerexception/10785 "2019-04-29T16:36:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![peterf98](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@peterf98](https://discourse.processing.org/u/peterf98)
#### Post date: [April 29, 2019, 4:36pm UTC](https://discourse.processing.org/t/csv-does-not-exist-or-could-not-be-read-nullpointerexception/10785/1 "2019-04-29T16:36:08Z")

</div>

I am having possibly the same problem. I have a .csv file with coordinates information that I want to draw. It worked fine this morning but can’t possibly get it to work now with error:  
“data/posit18.csv does not exist or could not be read  
NullPointerException”  
I am attaching (in next comment) code and .csv file.  
Thanks a lot.

---

<div class="post-metadata">

### Author: ![peterf98](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@peterf98](https://discourse.processing.org/u/peterf98)
#### Post date: [April 29, 2019, 4:36pm UTC](https://discourse.processing.org/t/csv-does-not-exist-or-could-not-be-read-nullpointerexception/10785/2 "2019-04-29T16:36:47Z")

</div>

```auto
Table table;
//PImage img1;

ArrayList<Float> x = new ArrayList<Float>();
ArrayList<Float> th1 = new ArrayList<Float>();
ArrayList<Float> th2 = new ArrayList<Float>();
ArrayList<Integer> F = new ArrayList<Integer>();
float X=0;
 int i=0;
 float pole1X, pole1Y,pole2X,pole2Y;
 float l1=200; 
 float l2=100;
float RecWidth=450;
float RecHeight=50;
float Offset=100;

void setup() {
  
  size(1300,600);
  frameRate(100);
  background(0);
  
  //img1 = loadImage("train.jpg");
  
  table = loadTable("data/posit1.csv", "header");
  println(table.getRowCount() + " total rows in table"); 
 
  for (TableRow row : table.rows()) {
 
    x.add(row.getFloat("x"));
    th1.add(row.getFloat("th1"));
    th2.add(row.getFloat("th2"));
    F.add(row.getInt("F"));
 
    
     //println("x= "+x+" th1= "+th1+" th2= "+th2);
  }
}

void draw(){
  if(i>x.size()-2){
   noLoop();
  }
  background(255);
  //println("x= "+x.get(i)+" th1= "+th1.get(i)+" th2= "+th2.get(i));
  stroke(255,0,0);
  line(0,0,0,height);
  line(width,0,width,height);
  
  
  
  stroke(0);
  fill(0);
  strokeWeight(4);
  line(0,height-50, width, height-50);
  rectMode(CENTER);
  X=map(x.get(i), -2.4, 2.4, RecWidth/2, width-RecWidth/2);
  println("x = "+x.get(i)+" - pxX = "+X+"\n");

  rect(X, height-75, RecWidth ,RecHeight);
  strokeWeight(10);
  stroke(139,69,19);
  pole1X=(X-Offset)+l1*(sin(th1.get(i)));
  pole1Y=(height-75-RecHeight/2-l1)-l1*cos(th1.get(i));
  line(X-Offset,height-75-RecHeight/2,pole1X,pole1Y);
  
  pole2X=(X+Offset)+l2*(sin(th2.get(i)));
  pole2Y=(height-75-RecHeight/2-l2)-l2*cos(th2.get(i));
  line(X+Offset,height-75-RecHeight/2,pole2X,pole2Y);
  stroke(0,255,0);
  fill(0,255,0);
  if(F.get(i)>8){
  triangle(X-RecWidth/2,height-75,X-RecWidth/2-100,height-125,X-RecWidth/2-100,height-25);
  }
  else if (F.get(i)<-8){
  triangle(X+RecWidth/2,height-75,X+RecWidth/2+100,height-125,X+RecWidth/2+100,height-25);
  }
  
  
  
  i++;
}

```

---

<div class="post-metadata">

### Author: ![peterf98](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@peterf98](https://discourse.processing.org/u/peterf98)
#### Post date: [April 29, 2019, 4:39pm UTC](https://discourse.processing.org/t/csv-does-not-exist-or-could-not-be-read-nullpointerexception/10785/3 "2019-04-29T16:39:17Z")

</div>

> **[‎⁨‎⁨posit18.csv](https://www.dropbox.com/s/idnkmmzss8vjlu1/%E2%80%8E%E2%81%A8%E2%80%8E%E2%81%A8posit18.csv?dl=0)**
>
> Shared with Dropbox

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [April 30, 2019, 6:18am UTC](https://discourse.processing.org/t/csv-does-not-exist-or-could-not-be-read-nullpointerexception/10785/4 "2019-04-30T06:18:05Z")

</div>

please open your own TOPIC

but read this one first about processing folder / file structure

also if you read that already you should know that  
info about path and filename is essential to this question

but code and data NOT,  
only the

```auto
Table table;
String infile = "data/posit18.csv";
//..
table = loadTable(infile, "header, csv");

```

* * *

but as you show this already  
even you get your project / file path correct

- – that is not a csv file!! should be like

```auto
x,th1,th2,F
-0.00099,0.018381,0.009091,-10
-0.00099,0.018419,0.009189,10

```

processing loadTable can only use true .csv .tsv

* * *

and i have no idea why you try transfer from table to array  
( only needed in rare occasions )
