# Process error column 4 dont exist

**URL:** https://discourse.processing.org/t/process-error-column-4-dont-exist/41075
**Category:** Coding Questions
**Created:** [February 26, 2023, 6:22pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075 "2023-02-26T18:22:38Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![ctremblay](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@ctremblay](https://discourse.processing.org/u/ctremblay)
#### Post date: [February 26, 2023, 6:22pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/1 "2023-02-26T18:22:38Z")

</div>

I’m coding a game and using tables. I have a bunch of lines of code that could easily be placed in a table to lessen the code, even though i’m sure everything is correct it keeps giving me an error. “Column 4 dont exist.” The table has 20 columns & row 1 has 6 numbers in it.  
roomT named room.csv

```auto
6,1,3,0,1,2,3,,,,,,,,,,,,,,,
9,4,10,4,5,6,7,8,9,10,,,,,,,,,,,,
12,11,20,11,12,13,14,15,16,17,18,19,20,,,,,,,,,
7,23,27,23,24,25,26,27,,,,,,,,,,,,,,
17,31,42,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,,,,
6,43,46,43,44,45,46,47,,,,,,,,,,,,,,
8,47,52,47,48,49,50,51,52,53,,,,,,,,,,,,
8,53,58,53,54,55,56,57,58,59,,,,,,,,,,,,
7,59,63,59,60,61,62,63,64,,,,,,,,,,,,,
7,64,68,64,65,66,67,68,69,,,,,,,,,,,,,
10,69,76,69,70,71,72,73,74,75,76,,,,,,,,,,,
10,77,84,77,78,79,80,81,82,83,84,85,,,,,,,,,,
7,85,89,85,86,87,88,89,90,,,,,,,,,,,,,
12,90,99,90,91,92,93,94,95,96,97,98,99,100,,,,,,,,
12,100,109,100,101,102,103,104,105,106,107,108,109,110,,,,,,,,
7,110,114,110,111,112,113,114,,,,,,,,,,,,,,
8,115,120,115,116,117,118,119,120,,,,,,,,,,,,,
7,124,128,124,125,126,127,128,,,,,,,,,,,,,,
8,129,134,129,130,131,132,133,134,,,,,,,,,,,,,

```

setup

```auto
Table roomT,storyT;
TableRow tr;
int minsx, maxsx;
ArrayList<Word> word = new ArrayList<Word>();
ArrayList<Room> room = new ArrayList<Room>();

void setup(){
  size(600,600);
  roomT = loadTable("room.csv");
  storyT = loadTable("word.csv","header");
  room.add(new Room(0));
}

void draw(){
  background(125,125,125);
  for (Word w: word){
    w.show();
  }
}

```

room

```auto
class Room{
  int num;
  
  Room(int n){
    num = n;
    tr = roomT.getRow(n);
    int tn = tr.getInt(0);
    for (int i = 3; i <= tn; i++){
      int nt = tr.getInt(i);// here the problem
      word.add(new Word(nt));
    }
  }
}

```

word

```auto
class Word{
  PVector pos;
  String name;
  int s;
  
  Word(int n){
    pos = new PVector(0,0);
    tr = storyT.getRow(n);
    name = tr.getString("Name");
    pos.x = tr.getFloat("X");
    pos.y = tr.getFloat("Y");
    s = tr.getInt("Size");
  }
  
  void show(){
    fill(0);
    textSize(s);
    text(name,pos.x,pos.y);
  }
}

```

storyT named word.csv

```auto
Name,X,Y,Size
Story Title,5,64,64
Play,5,192,64
Control,5,256,64
Score Board,5,320,64

```

Ive tried

```auto
void draw(){
  tr = roomT.getRow(0);
  int ts = tr.getInt(4);
  textSize(32);
  text(ts,5,32);
}

```

and 3 and 4 works just fine

i also tried

```auto
void setup(){
   int page = 0;
   tr = roomT.getRow(page);
  int tn = tr.getInt(0);
  int nt = tr.getInt(3);
  word.add(new Word(nt));
  nt = tr.getInt(4);
  word.add(new Word(nt));
  nt = tr.getInt(5);
  word.add(new Word(nt));
}

```

error on 4

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [February 26, 2023, 8:08pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/2 "2023-02-26T20:08:05Z")

</div>

> [@ctremblay](#):
>
> `for (int i = 3; i <= tn; i++){`

Consider  
`for (int i = 1; i < tn+1; i++){`

---

<div class="post-metadata">

### Author: ![ctremblay](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@ctremblay](https://discourse.processing.org/u/ctremblay)
#### Post date: [February 26, 2023, 8:20pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/3 "2023-02-26T20:20:12Z")

</div>

Why does it work in draw but not in setup()? As can clearly see column 4 does exist just fine. && 0 is the amount of words in room, 1 is miny in the room. 2 is maxy in room, so i need to start at 3 the number of the first word in the room.  
The same code in setup will fail but in draw will work

in draw works fine

```auto
Table roomT,storyT;
TableRow tr;
int minsx, maxsx;
ArrayList<Word> word = new ArrayList<Word>();
ArrayList<Room> room = new ArrayList<Room>();
int page = 0;

void setup(){
  size(600,600);
  roomT = loadTable("room.csv");
  storyT = loadTable("word.csv","header");
  //room.add(new Room(0));
}

void draw(){
  background(125,125,125);
  for (Word w: word){
    w.show();
  }
  tr = roomT.getRow(page);
  int tn = tr.getInt(0);
  for (int i = 3; i <= tn; i++){
    int nt = tr.getInt(i);
    textSize(32);
    text(nt,5,32*i);
  }
}

```

but i cant keep it in draw I only need the numbers once  
if read the bottom parts of the post you would see column 4 does exist

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [February 26, 2023, 8:46pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/4 "2023-02-26T20:46:58Z")

</div>

> [@ctremblay](#):
>
> ```auto
> Word(int n){
> pos = new PVector(0,0);
> tr = storyT.getRow(n);
> 
> ```

Maybe this causes the error when n==4?

---

<div class="post-metadata">

### Author: ![ctremblay](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@ctremblay](https://discourse.processing.org/u/ctremblay)
#### Post date: [February 26, 2023, 8:54pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/5 "2023-02-26T20:54:38Z")

</div>

the only things called from storyT are by name & storyT wasn’t made with a fourth column so the error still makes no sense.

storyT

```auto
Name,X,Y,Size
Story Title,5,64,64
Play,5,192,64
Control,5,256,64
Score Board,5,320,64

```

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [February 26, 2023, 8:57pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/6 "2023-02-26T20:57:26Z")

</div>

Story is called with row 4.

Did you try to comment this out:

> [@ctremblay](#):
>
> `word.add(new Word(nt));`

?

---

<div class="post-metadata">

### Author: ![ctremblay](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@ctremblay](https://discourse.processing.org/u/ctremblay)
#### Post date: [February 26, 2023, 9:04pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/7 "2023-02-26T21:04:18Z")

</div>

if the code worked how it should roomT 0,3 should return 0, which would give us. word.add(new Word(0));  
which worked when i typed the number in.  
0,4 would return 1 which then turns into

```auto
word.add(new Word(1));

```

again worked with number

0,5 would return 2 again works if i place a 2 in  
0,6 would return 3 again works if place 3 in, so looks like the problem is somewhere between roomT getting the number and roomT giving the number to word. I just tried

```auto
void draw(){
  background(125,125,125);
  for (Word w: word){
    w.show();
  }
  word.add(new Word(0));
  word.add(new Word(1));
  word.add(new Word(2));
  word.add(new Word(3));
}

```

those work just fine but adding words every frame would soon to be disaster.  
n in word is used to get the row not the column.  
Guess I’ll have to long code it. Dumb thing cant even get a simple number from the table, its retarded

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [February 26, 2023, 9:35pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/8 "2023-02-26T21:35:31Z")

</div>

You are right.

Work-around :

Just leave the data in the code and move it to a new tab

---

<div class="post-metadata">

### Author: ![ctremblay](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@ctremblay](https://discourse.processing.org/u/ctremblay)
#### Post date: [February 26, 2023, 9:37pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/9 "2023-02-26T21:37:06Z")

</div>

here the numbers i need the word works fine.

```auto
Table roomT,storyT;
TableRow tr;
int minsx, maxsx;
ArrayList<Word> word = new ArrayList<Word>();
ArrayList<Room> room = new ArrayList<Room>();
int page = 0;
boolean create = false;

void setup(){
  size(600,600);
  roomT = loadTable("room.csv");
  storyT = loadTable("word.csv","header");
  //room.add(new Room(0));
}

void draw(){
  background(125,125,125);
  for (Word w: word){
    w.show();
  }
  tr = roomT.getRow(0);
  int tn = tr.getInt(0);
  for (int i = 3; i <= tn; i++){
    int nt = tr.getInt(i);
    textSize(32);
    text(nt,5,32 + (32*i));
  }
}

```

here me manually placing those numbers in. without the for loop

```auto
ArrayList<Room> room = new ArrayList<Room>();
int page = 0;
boolean create = false;

void setup(){
  size(600,600);
  roomT = loadTable("room.csv");
  storyT = loadTable("word.csv","header");
  //room.add(new Room(0));
  word.add(new Word(0));
  word.add(new Word(1));
  word.add(new Word(2));
  word.add(new Word(3));
}

void draw(){
  background(125,125,125);
  for (Word w: word){
    w.show();
  }
  /*
  tr = roomT.getRow(0);
  int tn = tr.getInt(0);
  for (int i = 3; i <= tn; i++){
    int nt = tr.getInt(i);
    textSize(32);
    text(nt,5,32 + (32*i));
  }
  */
}

```

again code works fine showing there is not really an issue so how do i get what I want?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [February 27, 2023, 9:01am UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/10 "2023-02-27T09:01:30Z")

</div>

I can’t help you with that, sorry

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [February 27, 2023, 11:04am UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/11 "2023-02-27T11:04:59Z")

</div>

Hi @ctremblay,

The issue comes from you global variable TableRow tr, which is be used in Room and Word.

```auto
TableRow tr // global

class Room{
  Room(int n){
   ...
    tr = roomT.getRow(n); // using in Room

and 

class Word{
  ...
  Word(int n){
    ...
    tr = storyT.getRow(n); // changing in Word mess up the once in Room

```

Cheers  
— mnse

PS: So remove the global and define local TableRow’s where required …

---

<div class="post-metadata">

### Author: ![ctremblay](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@ctremblay](https://discourse.processing.org/u/ctremblay)
#### Post date: [February 27, 2023, 2:09pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/12 "2023-02-27T14:09:46Z")

</div>

it doesnt come from the global tr i use it all the time. NVM i made an easy work around not much more code

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [February 27, 2023, 3:39pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/13 "2023-02-27T15:39:42Z")

</div>

I’ve tested your initial approach and the issue is definitely the global tr. Also implemented a version without the global tr and it do exactly what it should do so far …  
Try to follow your code an in the first attempt on Room the tr referring a row of roomT and after constructor call of Word it changes the reference to a row of storyT. Back in the loop it says no column 4 because storyT hasn’t a column index 4 …

Cheers  
— mnse

---

<div class="post-metadata">

### Author: ![ctremblay](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@ctremblay](https://discourse.processing.org/u/ctremblay)
#### Post date: [February 27, 2023, 3:42pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/14 "2023-02-27T15:42:43Z")

</div>

if was the global tr my work around wouldnt work  
here what I did.

in room

```auto
tr = roomT.getRow(page);
    n1 = tr.getInt(3);
    minsx = tr.getInt(1);
    maxsx = tr.getInt(2);
    sx = minsx;
    for (int i = n1; i <= maxsx; i++){
      word.add(new Word(i));
    }

```

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [February 27, 2023, 4:10pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/15 "2023-02-27T16:10:10Z")

</div>

In your workaround you are not accessing the roomT in the loop again. That’s why it works …  
I can only recommend that you should try to understand what your code really is doing not just believe in what it should do in your opinion… eom

---

<div class="post-metadata">

### Author: ![ctremblay](https://avatars.discourse-cdn.com/v4/letter/c/e495f1/32.png) [@ctremblay](https://discourse.processing.org/u/ctremblay)
#### Post date: [February 27, 2023, 4:12pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/16 "2023-02-27T16:12:27Z")

</div>

i do access roomT, it’s the first line of code. and instead of directly sending the info into the words which i’m seeing little use for. i’m placing them in variables. See here i access roomT

```auto
tr = roomT.getRow(page);

```

I do understand what it does

tr = roomT.getRow(page);// access roomT to get my numbers  
n1 = tr.getInt(3);// set n1 so i know my lowest number  
minsx = tr.getInt(1);// set minsx should be sy so know where menu color will start  
maxsx = tr.getInt(2);// set maxsx so know high sx point  
sx = minsx;// set sx to minsx so can do my menu  
for (int i = n1; i \<= maxsx; i++){// looping through lowest to highest  
word.add(new Word(i));// creating the words  
}

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [February 27, 2023, 4:38pm UTC](https://discourse.processing.org/t/process-error-column-4-dont-exist/41075/17 "2023-02-27T16:38:19Z")

</div>

I think you not want to understand what I’m saying …  
I’ve already explained above what was wrong …

> [@mnse](#):
>
> in the first attempt on Room the tr referring a row of roomT and after constructor call of Word it changes the reference to a row of storyT. Back in the loop it says no column 4 because storyT hasn’t a column index 4 …

and why your workaround works…

> [@mnse](#):
>
> **In your workaround you are not accessing the roomT _in the loop_** again. That’s why it works …

I’ll stop further discussions here. Nevertheless, I wish you all the best …

Cheers  
— mnse
