Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8905399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:23:05+00:00 2026-06-15T02:23:05+00:00

I have some code in processing which reads in a CSV file and dumps

  • 0

I have some code in processing which reads in a CSV file and dumps it into an array. I then need to use this data in various methods to draw some exciting graphics.

However in the code below When I try to run the glyph method I get an exception that the program cant find anything called DSA. Can anyone point me in the right direction? Someone told me I should put “public” before defining the string but that just caused another error (unexpected token).

  void setup() {

  cp5 = new ControlP5(this);  
  cp5.addButton("Overview")
  .setValue(0)
  .setPosition(840, 10)
  .setSize(100, 19);

  cp5.addButton("Quadrant")
  .setValue(0)
  .setPosition(840, 30)
  .setSize(100, 19);

  cp5.addButton("Location Map")
  .setValue(0)
  .setPosition(840, 50)
  .setSize(100, 19);

String [][] DSA = readFile("DSA.csv");
String [][] NC = readFile("NC.csv");
String [][] IW = readFile("IW.csv");

  size(950, 600);
  smooth();
  //noStroke();
  //Use system font 'Arial' as the header font with 12 point type
  h1 = createFont("Arial", 12, false);
  //Use system font 'Arial' as the label font with 9 point type
  l1 = createFont("Arial", 9, false);

}
String [][] readFile(String fileName) {
  //for importing csv files into a 2d array
  //by che-wei wang

  String lines[] = loadStrings(fileName);
  String [][] csv;
  int csvWidth=0;

  //calculate max width of csv file
  for (int i=0; i < lines.length; i++) {
    String [] chars=split(lines[i], ',');
    if (chars.length>csvWidth) {
      csvWidth=chars.length;
    }
  }

  //create csv array based on # of rows and columns in csv file
  csv = new String [lines.length][csvWidth];

  //parse values into 2d array
  for (int i=0; i < lines.length; i++) {
    String [] temp = new String [lines.length];
    temp= split(lines[i], ',');
    for (int j=0; j < temp.length; j++) {
      csv[i][j]=temp[j];
    }
  }
  return csv;
}

void Gluph() {
    println(DSA[1][3])
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:23:06+00:00Added an answer on June 15, 2026 at 2:23 am

    This is a scoping problem. Read about variable scope.

    One solution is you could declare the variables in the global space. Right now they are declared in your setup() function, and once setup() exits, the variables are no longer available to other functions since they were declared within the setup() scope. If you declare them before setup(), on the very first line of your program, you’ll have access to them in the global scope.

    If you need to still readFile() within setup, then just declare the variables in the global scope and assign values in setup(). Since the variables are declared in the global scope, the changes in the setup() scope will still be reflected no matter where you access them from.

    String [][] DSA;
    String [][] NC;
    String [][] IW;   
    
    void setup() {
    
      cp5 = new ControlP5(this);  
      cp5.addButton("Overview")
      .setValue(0)
      .setPosition(840, 10)
      .setSize(100, 19);
    
      cp5.addButton("Quadrant")
      .setValue(0)
      .setPosition(840, 30)
      .setSize(100, 19);
    
      cp5.addButton("Location Map")
      .setValue(0)
      .setPosition(840, 50)
      .setSize(100, 19);
    
      DSA = readFile("DSA.csv");
      NC = readFile("NC.csv");
      IW = readFile("IW.csv");
    
      size(950, 600);
      smooth();
      //noStroke();
      //Use system font 'Arial' as the header font with 12 point type
      h1 = createFont("Arial", 12, false);
      //Use system font 'Arial' as the label font with 9 point type
      l1 = createFont("Arial", 9, false);
    
    }
    String [][] readFile(String fileName) {
      //for importing csv files into a 2d array
      //by che-wei wang
    
      String lines[] = loadStrings(fileName);
      String [][] csv;
      int csvWidth=0;
    
      //calculate max width of csv file
      for (int i=0; i < lines.length; i++) {
        String [] chars=split(lines[i], ',');
        if (chars.length>csvWidth) {
          csvWidth=chars.length;
        }
      }
    
      //create csv array based on # of rows and columns in csv file
      csv = new String [lines.length][csvWidth];
    
      //parse values into 2d array
      for (int i=0; i < lines.length; i++) {
        String [] temp = new String [lines.length];
        temp= split(lines[i], ',');
        for (int j=0; j < temp.length; j++) {
          csv[i][j]=temp[j];
        }
      }
      return csv;
    }
    
    void Gluph() {
        println(DSA[1][3])
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some python code which runs every 10 minutes or so. It reads
I'm developing some code which reads file names from an sd-card (using FatFs) and
I have some code as shown below: - (IBAction)startButtonPressed:(id)sender { statusText.text = @Processing...; //here
I am writing some Natural Language Processing code and want to have a binary
I have some code which takes strings representing hexadecimal numbers - hex colors, actually
I have to copy and do some simple processing on file. I can not
I have craeted code which reads the acc no, rtn, name and amt from
I have some code on two systems running kernel 2.4.20 and kernel 2.4.38 .
I have some code that will change the background color of a specific label
I have some code here that uses bitsets to store many 1 bit values

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.