# Trying to find a name in a table

**URL:** https://discourse.processing.org/t/trying-to-find-a-name-in-a-table/9498
**Category:** Coding Questions
**Created:** [March 21, 2019, 3:02am UTC](https://discourse.processing.org/t/trying-to-find-a-name-in-a-table/9498 "2019-03-21T03:02:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)
#### Post date: [March 21, 2019, 3:02am UTC](https://discourse.processing.org/t/trying-to-find-a-name-in-a-table/9498/1 "2019-03-21T03:02:57Z")

</div>

Hey, I’m making a card game & made a list of the cards in a table. I thought I could run through the list and match the card I want with the correct info in the table, but i’m getting the wrong info. I place Captain in, but it giving me the info for the first one in the list.  
here main:

```auto
Table CardTable;
TableRow CardRow;
ArrayList<Card> card = new ArrayList<Card>();

void setup(){
  size(600,600);
  CardTable = loadTable("card.csv","header");
  card.add(new Card("Captain"));// here i create the card
}
void draw(){
  background(0);
  for (int i = card.size()-1; i >= 0; i--){
    Card c = card.get(i);
    c.show();
  }
}

```

here card

```auto
class Card{
  int x,y,life,attack,common,row;
  String Name,Race,n;
  
  Card(String Name){
    this.Name = Name;
    for (int i = 0; i < 57; i++){
      CardRow = CardTable.getRow(i);
      n = CardRow.getString("Name");
      if (n == Name){
        row = i;
      }
    }
    get();
  }// card
  
  void get(){
    CardRow = CardTable.getRow(row);
    life = CardRow.getInt("Life");
    attack = CardRow.getInt("Attack");
    Race = CardRow.getString("Race");
    common = CardRow.getInt("Common");
  }
  
  void show(){
    textSize(10);
    text("Name: " + Name, 5, 10);
    text("Race: " + Race, 5, 20);
    text("Attack: " + attack, 5, 30);
    text("Life: " + life, 5, 40);
    text("Common: " + common, 5, 50);
    text("Row: " + row, 5, 60);
  }
}

```

the first 4 things in the table are

Name,Race,Attack,Life,Common  
Guard,Human,1,3,1  
Sentinel,Human,2,7,2  
Captain,Human,2,9,3

---

<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: [March 21, 2019, 3:55am UTC](https://discourse.processing.org/t/trying-to-find-a-name-in-a-table/9498/2 "2019-03-21T03:55:40Z")

</div>

[https://processing.org/reference/String\_equals\_.html](https://processing.org/reference/String_equals_.html)

```auto
// if (n == Name){
      if (n.equals(Name)){

```

anyhow check on  
[https://processing.org/reference/Table\_findRow\_.html](https://processing.org/reference/Table_findRow_.html)  
it does the search job for you.

---

<div class="post-metadata">

### Author: ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)
#### Post date: [March 21, 2019, 3:59am UTC](https://discourse.processing.org/t/trying-to-find-a-name-in-a-table/9498/3 "2019-03-21T03:59:06Z")

</div>

Thanks, that fixed my problem.
