Debugger says getStringColumn() does not exist

I have created a Table object using the following code:

dataTable = new Table("Freezer Stock.txt");

Now, I want to create arrays that have certain columns’ information so that I can create a dropdown menu. For some reason, the debugger is telling me that .getStringColumn() does not exist.

I am creating the lists as follows:

// Initialize lists for dropdown menu
freezerList = new String[rowCount];
shelfList = new String[rowCount];
rackList = new String[rowCount];
boxList = new String[rowCount];
  
// Populate lists
freezerList = dataTable.getStringColumn("Freezer");
shelfList = dataTable.getStringColumn("Shelf");
rackList = dataTable.getStringColumn("Rack");
boxList = dataTable.getStringColumn("Box");

Any idea what could be causing the issues? I can’t really divulge any of the freezer information since it is confidential, otherwise I would just upload my entire project file to Github.

1 Like

Just to make sure, but you declared dataTable like this somewhere, right?

Table dataTable;
//or 
Table dataTable = new Table();

// and then to load the Table you used 
dataTable = loadTable("myFile.csv");

Cause i don‘t think Table can simply be initialized like you did with a txt file…

Edit :
Yup, i‘m pretty sure these are the only available extensions :

static final String[] loadExtensions = { "csv", "tsv", "ods", "bin" };
static final String[] saveExtensions = { "csv", "tsv", "ods", "bin", "html" };
1 Like

Yes. I declared dataTable as

Table dataTable;

And I used the following load the data

dataTable = new Table("myFile.csv);

Processing.org/reference/loadTable_.html

Do I need to include an import at the beginning of my code to use Table? I had been using a Table class from a textbook until now.

Are you sure you did that, because in your Original post you said you did something different… so, what extension does your file have? .csv or .txt?

It is a .txt file, but using a .csv doesn’t work, either. Also, my sketch now says Table dataTable; is ambiguous. Is there some sort of .pde I need to include to get Table to work properly? Any import statement that include the libraries for the Table class?

No, Table is already integrated…

A .txt file will not work, because it‘s not a supported Extension for Table.

As for the ambiguous part, that‘s probably because you tried importing another class called Table, right? This error happens when there are 2 or more conflicting namespaces…

For example :

import java.fun.MyClass;
import com.sun.funnier.MyClass;

//then defining 

MyClass myVariable; //The Compiler has no idea wether you are Talking about java.fun.MyClass or com.sun.funnier.MyClass...

I ditched the Table class I had been using, but that’s when the ambiguity issues began. I had no issue with ambiguity before tossing out the modified Table class I was using. That’s what has me so confused.

Since i don’t have Access to your Code, i can‘t help you much, but you just need to search your Code for the word Table being used to define a Class, so something like this :

Table rasa;

a = (Table) rasa;

b = new Table();

Pretty much anywhere you have the word Table to represent a class.

Now if one of These is something like :

import com.something.Table;

/or 

class Table {}
//or
class Table extends Something {}

Any of those are causing the issue.

Well, I imported the ControlP5 library. Perhaps that’s what’s causing the issues.

That shouldn‘t be the case, since it doesn’t have another variable called Table…

Please post the error Message you got, maybe that‘s gonna help.

Well, I am getting multiple errors, but they are all because of this one:

  • The type Table is ambiguous

Then somewhere in your Code you Must have 2 classes with the same name Table.

I’ll just send all of my code.

import controlP5.*;
ControlP5 cp5;

DropdownList freezer, shelf, rack, box;
int cnt = 0;

PImage image5x5;
PImage image9x9;
int rowCount5x5;
int rowCount9x9;
int rowCount;
String[] freezerList;
String[] shelfList;
String[] rackList;
String[] boxList;

Table locationTable5x5;
Table locationTable9x9;
Table dataTable;
int slotNumber;
String title = "Freezer Lookup Tool";
String filePath;
Boolean x9 = true;
Boolean x5 = true;

void setup(){
  size(1140, 900);
  
  // Create buttons using controlP5 library
  cp5 = new ControlP5(this);
  cp5.addButton("x9").setValue(0).setPosition(830, 490).setSize(60, 60);
  cp5.addButton("x5").setValue(0).setPosition(910, 490).setSize(60, 60);
  
  cp5.addDropdownList("freezer").setPosition(830, 130);
  cp5.addDropdownList("shelf").setPosition(830, 250).setSize(100, 40);
  cp5.addDropdownList("rack").setPosition(830, 370).setSize(100, 40);
  //cp5.addDropdownList("box").setPosition(830, 490).setSize(100, 40);

  // Load grids that will be used for 
  // representing each cryobox
  image5x5 = loadImage("5x5_grid.png");
  image9x9 = loadImage("9x9_grid.png");
  
  locationTable5x5 = new Table("loc_5x5.txt");
  locationTable9x9 = new Table("loc_9x9.txt");
  
  rowCount5x5 = locationTable5x5.getRowCount();
  rowCount9x9 = locationTable9x9.getRowCount();
  
  slotNumber = 1;
  
  // Load .txt of inventory
  dataTable = loadTable("Freezer Stock.csv");
  rowCount = dataTable.getRowCount();
  
  fillLists(rowCount);
}
  
  // Create unique lists of value for dropdown menu

void draw(){
  background(0);
  background(192, 100, 100);
  
  // Draw title background box
  textSize(48);
  fill(255, 200);
  stroke(2);
  rect(10, 10, textWidth(title) + 10, 63, 5);
  noStroke();
  
  // Draw Title
  fill(0);
  text(title, 10, 58);
  
  // Draw image
  //image(image9x9, 0, 90);
  // Draw slot numbers on grid
  //draw9x9();
  if (x5) {
    // If x9 was previously active, turn off
    x9 = false;

    image(image5x5, 0, 90);
    draw5x5();
  }
  
  if (x9) {
    // If x5 was previously active, turn off
    x5 = false;

    image(image9x9, 0, 90);
    draw9x9();
  }
  
  smooth();
  fill(0);
  noStroke();
  
  drawMenuBox();
}

////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//                  ADDITIONAL FUNCTIONS                  //
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
void draw5x5(){
  for (int row = 0; row < rowCount5x5; row++){
    float x = locationTable5x5.getFloat(row, 0); // column 1
    float y = locationTable5x5.getFloat(row, 1); // column 2
    
    textSize(24);
    text(row + 1, x + 4, y + 28);
  }
}

void draw9x9(){
  for (int row = 0; row < rowCount9x9; row++){
    float x = locationTable9x9.getFloat(row, 0); // column 1
    float y = locationTable9x9.getFloat(row, 1); // column 2
    
    textSize(12);
    text(row + 1, x + 4, y + 16);
  }
}

void drawMenuBox(){
  fill(255, 200);
  stroke(2);
  rect(820, 90, 310, 800, 5);
  
  fill(0);
  noStroke();
  textSize(24);
  text("Freezer", 830, 120);
  text("Shelf", 830, 240);
  text("Rack", 830, 360);
  text("Box", 830, 480);
}

// Button Logic
public void x9(){
  if(!x9){
    x9 = true;
  } else {
    x9 = false;
  }
}

// Button Logic
public void x5(){
  if(!x5){
    x5 = true;
  } else {
    x5 = false;
  }
}

void fillLists(int rowCount){
  // Initialize lists for dropdown menu
  freezerList = new String[rowCount];
  shelfList = new String[rowCount];
  rackList = new String[rowCount];
  boxList = new String[rowCount];
  
  // Populate lists
  freezerList = dataTable.getStringColumn("Freezer");
  shelfList = dataTable.getStringColumn("Shelf");
  rackList = dataTable.getStringColumn("Rack");
  boxList = dataTable.getStringColumn("Box");
}
1 Like

This is the problem. New Table doesn‘t accept .txt files. Replace these lines with :

locationTable9x9 = loadTable("loc_9x9.txt");
locationTable5x5 = loadTable("loc_5x5.txt");

And it should all be good.

2 Likes

I found out what the problem was with the Table ambiguity. I had some .jar files loaded that I was going to use to read directly from a MS Access file. I removed them and the conflict went away. Thanks for the help! I really appreciate it!

1 Like