<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with loadtable() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=loadtable%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:12:54 +0000</pubDate>
         <description>Tagged with loadtable() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedloadtable%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>max value in an Array</title>
      <link>https://forum.processing.org/two/discussion/28014/max-value-in-an-array</link>
      <pubDate>Wed, 23 May 2018 20:02:37 +0000</pubDate>
      <dc:creator>ermina</dc:creator>
      <guid isPermaLink="false">28014@/two/discussions</guid>
      <description><![CDATA[<p>In the code bellow i load a csv file and i want to find the maximum value from the column..
Where the name(header) of the column in the csv file is values.
But i get the error NullPointerException</p>

<pre><code>    String filename = "abc.csv";
    String[] rawData;
    float[] values;

    void setup() {
      rawData = loadStrings(filename);
      for (int i=1; i&lt;rawData.length; i++) {
        String[] thisRow = split(rawData[i], ",");
        values[i-1] = int(thisRow[1]);

      }

    if (values.length == 0) 
    {
      println("nothing in the array.");

    } else {
      float maxValue =  values[0];
      int maxIndex = 0;
      for (int i = 1; i &lt;  values.length; i++) {
        if ( values[i] &gt; maxValue) {
      maxValue = values[i];
      maxIndex = i;
        }
      }
      print("max value is " + maxValue);
      println(" at position " + maxIndex);
    }
      }


    void draw() {

    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Frame Rate keeps getting lower</title>
      <link>https://forum.processing.org/two/discussion/27931/frame-rate-keeps-getting-lower</link>
      <pubDate>Mon, 07 May 2018 06:13:02 +0000</pubDate>
      <dc:creator>dehyde</dc:creator>
      <guid isPermaLink="false">27931@/two/discussions</guid>
      <description><![CDATA[<p>Hi</p>

<p>I working on a code running particles to represent refugee data
The code limits the number of particles to keep the frameRate but even after using a steady number of particles, it keeps getting slower with lower frameRate.</p>

<p>I'm really not sure what I can do to make this run faster / smoother. Why does it keep getting slower?</p>

<p>Here's the data folder for the Sketch:
<a href="https://www.dropbox.com/sh/z69phco3tahqklu/AAB8PLMpBQMoFUX5NGSie-5fa?dl=0" target="_blank" rel="nofollow">https://www.dropbox.com/sh/z69phco3tahqklu/AAB8PLMpBQMoFUX5NGSie-5fa?dl=0</a></p>

<pre><code>PImage texture;
PGraphics pg;
PShape worldMap;
import java.util.Map;  
int filterPSystemsNum;

PGraphics sumPG;

// ========== Table Data Stuff 

Table immigrationTable;
Table conflictTable;
Table countryLocations;

int k = 0;
String[] destCountryArray = new String[0];
String[] sourceCountryArray = new String[0];

String destCountry = "";
String prevDestCountry = "";

String sourceCountry;

float mapMultiplyX = 4;
float mapOffsetX = -100;
float mapMultiplyY = 4;
float mapOffsetY = 50;

// ========

int amountSum = 1;

String displayType = "Circular";

int maxParticles = 9000;

ParticleSystem ps;
ParticleSystem ps2;

int n = 0, n2=0;
int emmitMultiplyer = 1;
int emmitFreq = 1;
float particleSpeed = 1;

float locationX = 250;
float locationY = 450;

int[] sourceX = {10, 40, 200, 400, 700};
int[] destX = {300, 600, 300, 600, 600};
int[] amount = {10, 100, 500, 800, 1000};
int highestAmount;

float radius = 300;

float tempLong;
float tempLat;

int yearFilterMin = 1996;
int yearFilterMax = 2016;


ParticleSystem[] PSystems;

HashMap&lt;String, Country&gt; countries = new HashMap&lt;String, Country&gt;();

void setup() {
  size(1200, 800, P2D);
  ((PGraphicsOpenGL)g).textureSampling(3);

  texture = loadImage("paper_texture.jpg");
  //worldMap = loadShape("worldLow.svg");

  //=============== load immigrationTable and create an array of countries


  immigrationTable = loadTable("asylum_seekers_all.csv", "header");
  countryLocations = loadTable("LatLonCountries2.csv", "header");
  conflictTable = loadTable("ged171.csv", "header");

  destCountryArray = (String[]) append(destCountryArray, "Israel");

  sumPG = createGraphics(width, height);

  pg = createGraphics(width, height);
  pg.beginDraw();
  pg.background(177);

  pg.endDraw();
  image(pg, 0, 0);

  for (TableRow row : immigrationTable.rows()) {
    if (row.getInt("Year") &lt;= yearFilterMax &amp;&amp; row.getInt("Year") &gt;= yearFilterMin) {

      String tempCountryHolder = row.getString("Country / territory of asylum/residence");

      boolean exists = countryExists(tempCountryHolder);
      if (exists==true) {

        continue;
      }

      destCountryArray = (String[]) append(destCountryArray, tempCountryHolder);
    }
  }

  for (TableRow row : immigrationTable.rows()) {
    if (row.getInt("Year") &lt;= yearFilterMax &amp;&amp; row.getInt("Year") &gt;= yearFilterMin) {

      String tempCountryHolder = row.getString("Origin");

      boolean exists = countryExists(tempCountryHolder);
      if (exists==true) { //println("exists, skipping");
        continue;
      }
      destCountryArray = (String[]) append(destCountryArray, tempCountryHolder);
    }
  }
  destCountryArray = sort(destCountryArray);



  //============================ country hashmaps ======================================

  for (int i = 0; i &lt; destCountryArray.length; i++) {
    String name = destCountryArray[i];




    for (TableRow row : countryLocations.rows()) {


      if (name.equals(row.getString("name"))) {

        tempLong = row.getFloat("longitude");
        tempLat = row.getFloat("latitude");
      }
    }

    countries.put(name, new Country(name, width/2+(tempLong*mapMultiplyX)+mapOffsetX, height/2-(tempLat*mapMultiplyY)+mapOffsetY));

  }

  for (String key : countries.keySet()) {
    Country c = countries.get(key);

  }

  //============================ PSystems =============

  PSystems = new ParticleSystem[immigrationTable.getRowCount()];
  int j = 0;

highestAmount = 291664;

  println(amountSum);
  for (TableRow row : immigrationTable.rows()) {
    if (row.getInt("Year") &lt;= yearFilterMax &amp;&amp; row.getInt("Year") &gt;= yearFilterMin) {
      int tempAmount = row.getInt("decisions_recognized");
      String tempDestCountry = row.getString("Country / territory of asylum/residence");
      String tempSourceCountry = row.getString("Origin");
      int tempYear = row.getInt("Year");

      float sourceEmmiterX = countries.get(tempSourceCountry).x;
      float sourceEmmiterY = countries.get(tempSourceCountry).y;
      float destEmmiterX = countries.get(tempDestCountry).x;
      float destEmitterY = countries.get(tempDestCountry).y;

      PSystems[j] = new ParticleSystem(1, new Vector3D(sourceEmmiterX, sourceEmmiterY, 0), new Vector3D(destEmmiterX, destEmitterY, 0), tempAmount, tempYear);
      println("----");
      filterPSystemsNum++;

      println("tempAmount "+tempAmount);
      println("maxParticles "+maxParticles);
      println("amountSum "+amountSum);
      println("tempAmount*maxParticles "+tempAmount*maxParticles);
      println("tempAmount*(maxParticles/amountSum) "+tempAmount*maxParticles/amountSum); 
      //println("PSystems " + i + " is " +PSystems[i]);
      j++;
    }
  }

  smooth();
}
int currentYear = 2000;
void draw() {

  blendMode(MULTIPLY);
  background(247, 245, 246, 1);
  fill(1, 1, 1, 1);

  tint(255, 1);
  image(pg, 0, 0);

  for (int i = 0; i&lt;filterPSystemsNum; i++) {

    boolean overCountryOrigin = overCountry(int(PSystems[i].origin.x), int(PSystems[i].origin.y), 10);
    boolean overCountryDest = overCountry(int(PSystems[i].dest.x), int(PSystems[i].dest.y), 10);
    boolean isOver = (overCountryOrigin || overCountryDest);
    PSystems[i].run(isOver);
  }


  //  =======

  int allPCount = 0;
  for (int k = 0; k&lt;filterPSystemsNum; k++) {

    Vector3D b=new Vector3D(PSystems[k].origin.x, PSystems[k].origin.y+abs(PSystems[k].origin.x-PSystems[k].dest.x)/2, 0);
    Vector3D c=new Vector3D(PSystems[k].dest.x, PSystems[k].dest.y+abs(PSystems[k].origin.x-PSystems[k].dest.x)/2, 0);


    boolean isTherePLimit = PSystems[k].PLimit != 0;

    if (isTherePLimit){

    boolean isThisAPlayingFrame = frameCount % int(sqrt(highestAmount/PSystems[k].PLimit)) == 0;
    boolean isThisTheRightYear = PSystems[k].year == currentYear;
    boolean areThereAnyMoreParticles = PSystems[k].PCount&lt;PSystems[k].PLimit;

    if (isThisAPlayingFrame &amp;&amp; isThisTheRightYear &amp;&amp; areThereAnyMoreParticles) {
      for(int s = 0; s&lt;emmitMultiplyer; s++){
      PSystems[k].addParticle();
      PSystems[k].PCount++;
      n++;
      }
    }
  }
    }



  // =========================================================== country labels




  for (int i = 0; i&lt;destCountryArray.length; i++) {
    float tempX = countries.get(destCountryArray[i]).x;
    float tempY = countries.get(destCountryArray[i]).y;
    float tempAng = atan((tempY-height/2)/(tempX-width/2));
    float labelMargin;
    translate(tempX, tempY);
    textSize(8);

    rotate(tempAng);
    fill(0);
    if (tempX&lt;width/2) {
      textAlign(RIGHT);
      labelMargin = -7;
    } else {
      textAlign(LEFT);
      labelMargin = 7;
    }

    if (overCountry(int(tempX), int(tempY), 9)==true) {
      fill(50, 100, 250);
      ellipse(0, 0, 5, 5);
      fill(0, 0, 255);
      text(countries.get(destCountryArray[i]).name, labelMargin, 2);
    } else {
      fill (200);
      fill(30, 100-sq(dist(mouseX, mouseY, tempX, tempY)));
      text(countries.get(destCountryArray[i]).name, labelMargin, 2);
    }

    if (countries.get(destCountryArray[i]).name == "Israel") {

      textAlign(RIGHT);
      textSize(10);
      fill(255);
      rotate(-tempAng);
      translate(-tempX, -tempY);
      rect(-6, -8, -textWidth("you are here")-7, 14);

      fill(200, 40, 40);
      text ("you are here", mouseX, mouseY);
      noFill();
      strokeWeight(0.5);
      stroke(255, 0, 0);

      bezier(mouseX, mouseY, (mouseX+tempX)/2+100, mouseY, tempX, (mouseY+tempY)/2, tempX, tempY);
      noStroke();
      translate(tempX, tempY);
      rotate(tempAng);
      ellipse(0, 0, 4, 4);
    }
    rotate(-tempAng);
    translate(-tempX, -tempY);
  }

  fill(0);
  text("Frame rate: "
    + int(frameRate), 10, 20);
  text("Each point: " + int(amountSum/maxParticles) +" people", 10, 30);
  text("number of refugees: " + n*int(amountSum/maxParticles), 10, 40);
  text("number of particles is: " +n, 10, 50);
  text("max particles is: " +maxParticles, 10, 60);
  textSize(80);
  blendMode(BLEND);
  fill(128, 130, 131);
  text(round(float(n)*float(amountSum)/float(maxParticles)), 10, 160);
  textSize(20);
  text("RECOGNIZED REFUGEES (" +yearFilterMin+ " - " + yearFilterMax+")", 10, 180);

  println("n = "+n);
  println("amountSum = "+amountSum);
  println("maxParticles = "+maxParticles);
}




// ==============================//  A simple Particle class  // ===============================================//




class Particle {

  Vector3D loc;
  Vector3D des;
  Vector3D vel;
  Vector3D acc;
  Vector3D locHome, b, c;
  float relativeSpeed;

  float r;
  float timer;

  float t=0.0; 
  float a = random(TWO_PI);
  Particle(Vector3D l, Vector3D m, int accum) {

    acc = new Vector3D(0, 0, 0); //  new Vector3D(random(-0.1, 0.1), random(-0.02, 0), 0);
    loc = l.copy();
    des = m.copy();
    locHome = l.copy();

    float rescale = 0.5;

    locHome.x = locHome.x+ cos(a)*random(0, sqrt(accum)*rescale);
    locHome.y = locHome.y+ sin(a)*random(0, sqrt(accum)*rescale);


    des.x = des.x+ cos(a)*random(0, sqrt(accum)*rescale);
    des.y = des.y+ sin(a)*random(0, sqrt(accum)*rescale);

    relativeSpeed = random(0.1, 0.02);


    r = random(0.9, 3);  // particle radius
    timer = 10000.0;   // particles lifespan


    b=new Vector3D(l.copy().x, l.copy().y+abs(l.copy().x-m.copy().x)/2, 0);
    c=new Vector3D(m.copy().x, m.copy().y+abs(l.copy().x-m.copy().x)/2, 0);

  }

  void run(boolean onMouseOverPSystem) {
    update();
    render(onMouseOverPSystem);
  }



  // Method to update location
  void update() {
    if (t&gt;=1)
      return;

    loc.x = bezierPoint(locHome.x, b.x, c.x, des.x, t);
    loc.y = bezierPoint(locHome.y, b.y, c.y, des.y, t);

    t = lerp(t, 1, particleSpeed*relativeSpeed/2);

  }

  void render(boolean isSelected) {
    ellipseMode(CENTER);
    noStroke();
    blendMode(BLEND);

    if (isSelected == false) {
      fill(128, 129, 129, 150);
    } 
    if (t==lerp(0, 1, particleSpeed*relativeSpeed/2)) {
      pg.beginDraw();
      pg.blendMode(BLEND);
      pg.fill(0, 0, 0);
      pg.noStroke();
      pg.ellipse(loc.x, loc.y, r, r);
      pg.endDraw();
    } else { 
      fill(4*255*t-3*255);
    }
    ellipse(loc.x, loc.y, r, r);

  }

  // Is the particle still useful?
  boolean dead() {
    if (t==1) {
      pg.beginDraw();
      pg.blendMode(BLEND);
      pg.fill(255, 255, 255, 255);
      pg.noStroke();
      pg.ellipse(loc.x, loc.y, r, r);
      pg.endDraw();
      return true;
    } else {
      return false;
    }
  }
}


// ==============================//  A ParticleSystem  // ===============================================// 


// A class to describe a group of Particles
// An ArrayList is used to manage the list of Particles
class ParticleSystem {

  ArrayList particles;    // An arraylist for all the particles
  Vector3D origin;        // An origin point for where particles are birthed
  Vector3D dest;
  int PLimit;
  int PCount;
  int year;

  float ratio = PLimit/highestAmount;

  //ParticleSystem( number of particles / frame, source, destination, frequency);
  ParticleSystem(int num, Vector3D v, Vector3D d, int f, int y) {
    particles = new ArrayList();              // Initialize the arraylist
    origin = v.copy();     // Store the origin point
    dest = d.copy();
    year = y;
    PLimit = f;


    //if (frameCount % (1/f) == 0){
    for (int i = 0; i &lt; num; i++) {
      //  particles.add(new Particle(origin, dest));    // Add "num" amount of particles to the arraylist
    }
    //}
  }

  void run(boolean onMouseOverPSystem) {


    for (int i = particles.size()-1; i &gt;= 0; i--) {
      Particle p = (Particle) particles.get(i);
      p.run(onMouseOverPSystem);
      if (p.dead()) {
        particles.remove(i);
        //PCount--;
        //n--;
      }

    }
  }

  void addParticle() {
    particles.add(new Particle(origin, dest, PCount));
  }



  // A method to test if the particle system still has particles
  boolean dead() {
    if (particles.isEmpty()) {
      return true;
    } else {
      return false;
    }
  }
}

//=================================================== Class Country

class Country {
  String name;
  float x, y, lon, lat, migrationIndex, incoming, outgoing;
  // more things here?

  Country(String name, float x, float y) {
    this.name = name;
    this.x = x;
    this.y = y;
  }
}

// ================================================ Simple Vector3D Class


public class Vector3D {

  public float x;
  public float y;
  public float z;

  Vector3D(float x_, float y_, float z_) {
    x = x_; 
    y = y_; 
    z = z_;
  }

  Vector3D(float x_, float y_) {
    x = x_; 
    y = y_; 
    z = 0f;
  }

  Vector3D() {
    x = 0f; 
    y = 0f; 
    z = 0f;
  }

  void setX(float x_) {
    x = x_;
  }

  void setY(float y_) {
    y = y_;
  }

  void setZ(float z_) {
    z = z_;
  }

  void setXY(float x_, float y_) {
    x = x_;
    y = y_;
  }

  void setXYZ(float x_, float y_, float z_) {
    x = x_;
    y = y_;
    z = z_;
  }

  void setXYZ(Vector3D v) {
    x = v.x;
    y = v.y;
    z = v.z;
  }

  public float magnitude() {
    return (float) Math.sqrt(x*x + y*y + z*z);
  }

  public Vector3D copy() {
    return new Vector3D(x, y, z);
  }

  public Vector3D copy(Vector3D v) {
    return new Vector3D(v.x, v.y, v.z);
  }

  public void add(Vector3D v) {
    x += v.x;
    y += v.y;
    z += v.z;
  }

  public void sub(Vector3D v) {
    x -= v.x;
    y -= v.y;
    z -= v.z;
  }

  public void mult(float n) {
    x *= n;
    y *= n;
    z *= n;
  }

  public void div(float n) {
    x /= n;
    y /= n;
    z /= n;
  }

  public void normalize() {
    float m = magnitude();
    if (m &gt; 0) {
      div(m);
    }
  }

  public void limit(float max) {
    if (magnitude() &gt; max) {
      normalize();
      mult(max);
    }
  }

  public float heading2D() {
    float angle = (float) Math.atan2(-y, x);
    return -1*angle;
  }

  public Vector3D add(Vector3D v1, Vector3D v2) {
    Vector3D v = new Vector3D(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
    return v;
  }

  public Vector3D sub(Vector3D v1, Vector3D v2) {
    Vector3D v = new Vector3D(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
    return v;
  }

  public Vector3D div(Vector3D v1, float n) {
    Vector3D v = new Vector3D(v1.x/n, v1.y/n, v1.z/n);
    return v;
  }

  public Vector3D mult(Vector3D v1, float n) {
    Vector3D v = new Vector3D(v1.x*n, v1.y*n, v1.z*n);
    return v;
  }

  public float distance (Vector3D v1, Vector3D v2) {
    float dx = v1.x - v2.x;
    float dy = v1.y - v2.y;
    float dz = v1.z - v2.z;
    return (float) Math.sqrt(dx*dx + dy*dy + dz*dz);
  }
}

boolean countryExists(String tempCountryHolder) {

  for (int i = 0; i &lt; destCountryArray.length; i++) {

    if (tempCountryHolder.equals(destCountryArray[i]) == true) {

      return true; // it exists
    } //if
  } //for
  return false ; // not found
}//func


//============================================= onMouseOver Bolean Class


boolean overParticle(int x, int y, int diameter) {
  float disX = x - mouseX;
  float disY = y - mouseY;
  if (sqrt(sq(disX) + sq(disY)) &lt; diameter/2 ) {
    return true;
  } else {
    return false;
  }
}

boolean overCountry(int x, int y, int diameter) {
  float disX = x - mouseX;
  float disY = y - mouseY;
  if (sqrt(sq(disX) + sq(disY)) &lt; diameter/2 ) {
    return true;
  } else {
    return false;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>SinOsc to play through an IntList</title>
      <link>https://forum.processing.org/two/discussion/27865/sinosc-to-play-through-an-intlist</link>
      <pubDate>Fri, 27 Apr 2018 17:54:34 +0000</pubDate>
      <dc:creator>mfuster</dc:creator>
      <guid isPermaLink="false">27865@/two/discussions</guid>
      <description><![CDATA[<p>Hi, 
I'm trying to get SinOsc to play through an IntList. The IntList values will be mapped so that their values change the frequency output. I would like to be able to control the timing of the sounds (e.g., one sound per second).
However, I'm running into all sorts of problems, starting with map() as it will only accept floats. Never mind trying to make it play through the IntList.</p>

<p>The following is the code I have that works so far (all failed attempts at playing the sounds have been omitted):</p>

<pre><code>import processing.sound.*;
IntList luxSample1;
final int sampleSize=10;
Table table;
TableRow row;
float luxData;
float luxNoise1;
PFont font;
int RowCount; //total rows
int index; // random starting point
int end = index+9;
int [] randomLux1 = new int [10];
int minLux1, maxLux1;
SinOsc sine1;
String date;


void setup() {
  processData();
  size(640, 600); 
  background(0);
  font = createFont("Arial", 14, true);

  //Processing sound
  sine1 = new SinOsc(this);
  sine1.play();
}

void draw () {
  background(0);
  fill(255);
  textFont(font);
  textAlign(LEFT);
  date = table.getString(1, 0);
  text(date, 20, 20);
}
void processData() {
  table = loadTable("sample.csv", "header"); //change file here
  RowCount = table.getRowCount();

  index = int(random(RowCount-sampleSize));

  int[] randomLux1 = int(table.getStringColumn("lux"));
  luxSample1 = new IntList();
  luxSample1.append(subset(randomLux1, index, sampleSize));
  println(luxSample1);
  minLux1 = min(subset(randomLux1, index, sampleSize));
  maxLux1 = max(subset(randomLux1, index, sampleSize));
  println(minLux1, maxLux1);
}
</code></pre>

<p>The data is taken from a .csv file. Here is a sample:
date,time,lux
02.08.2016,9:27:28,866
02.08.2016,9:27:29,635
02.08.2016,9:27:30,949
02.08.2016,9:27:31,986
02.08.2016,9:27:33,987
02.08.2016,9:27:34,992
02.08.2016,9:27:40,980
02.08.2016,9:27:44,987
02.08.2016,9:27:45,981
02.08.2016,9:27:46,977
02.08.2016,9:27:47,977
02.08.2016,9:27:48,974</p>

<p>Any pointers or help as to where I am going wrong or what I should look into will be greatly appreciated.
Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Use 2D array to find coincidences of words</title>
      <link>https://forum.processing.org/two/discussion/27481/use-2d-array-to-find-coincidences-of-words</link>
      <pubDate>Thu, 29 Mar 2018 18:41:07 +0000</pubDate>
      <dc:creator>Rayle</dc:creator>
      <guid isPermaLink="false">27481@/two/discussions</guid>
      <description><![CDATA[<p>I am triying to discover how many times words from a list appear together in the sentences of a given text. The first thing I did was to find the sentences with a particular word (law in the example below), make an array with them, and count the times the other words appear with an <code>IntDict</code>.</p>

<p>This is the code</p>

<pre><code>StringList results;
IntDict coincidence;

void setup() {

  String [] text = loadStrings("text.txt");
  String onePhrase = join(text, " ").toLowerCase();
  String [] phrases = splitTokens(onePhrase, ".?!");
  String search = "\\blaw.?\\b";
  String [] wordList = loadStrings("wordList.txt");

for (int i = 0; i&lt;phrases.length; i ++) {
      String [] matching = match(phrases[i], search);
      if (matching != null) {
        results.append(phrases[i]); 
    }
  }

   String [] resultsArray = results.array();

   String joinResults = join(resultsArray, " ");
   String [] splitResults = splitTokens(joinResults, " -,.:;¿?¿!/_");

    for(int i = 0; i &lt; splitResults.length; i++) {
    for (String searching : wordList) {
      if (splitResults[i].equals(searching)){
      coincidence.increment(splitResults[i]);
    }
   }
  }
</code></pre>

<p>But if I want to count how many times each word of the list appears together with the other ones, I need to remake the process a lot of times.</p>

<p>I tried with <code>Array[][]</code> but it doesn't work. Now I am stuck with the problem and I don't know how to proceed. I would appreciate any idea.</p>

<pre><code>StringList list;
String [] search;

void setup() {

  String [] text = loadStrings("text.txt");
  String onePhrase = join(text, " ").toLowerCase();
  String [] phrases = splitTokens(onePhrase, ".?!");

  Table table = loadTable("listOfWords.csv", "header");

  for (int i = 0; i &lt;table.getRowCount(); i ++) {
   TableRow row = table.getRow(i);
   list.append(row.getString("Word"));
   search = list.array();
  }

  for (int i = 0; i &lt; phrases.length; i ++) {
    for (int j = 0; j &lt; search.length; j ++) {
      String [][] matching = matchAll(phrases[i], search[j]);

       printArray(matching);
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>how to read and display points(read coordinate information from CSV file) over time?</title>
      <link>https://forum.processing.org/two/discussion/26209/how-to-read-and-display-points-read-coordinate-information-from-csv-file-over-time</link>
      <pubDate>Thu, 01 Feb 2018 15:35:17 +0000</pubDate>
      <dc:creator>littleprince84</dc:creator>
      <guid isPermaLink="false">26209@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm very beginner. I really need your help.</p>

<p>My project is...</p>

<ol>
<li><p>display amount of  activities(which done on same day, date and time / described as circle size) for each 5 different points 
on the map.</p></li>
<li><p>if you finished to display activities of 5 points for day1, date1 and time 0, 
then now display 5 points for time1...and so on(for time 2, time 3, time 4.....)</p></li>
<li><p>if you finish displaying 5 points for the 1st day, now 
do the same thing for the next(2nd day)</p></li>
<li><p>the result needs to be "animation" which shows the movement of activities on 5 points on the map over time(by time and 
then date)</p></li>
</ol>

<p>The structure of CSV(which includes the information of location, amount of activities, time and date) file is as follow</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/037/SLVGTY0VUF44.jpg" alt="Picture1" title="Picture1" /></p>

<p>I've tried to display for the first day of first time(time00) by using this code.
(I erased time01~05 for this test)</p>

<pre><code>import com.reades.mapthing.*;
import net.divbyzero.gpx.*;
import net.divbyzero.gpx.parser.*;
import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.unfolding.providers.*;

UnfoldingMap map;

ArrayList&lt;Position&gt; admins = new ArrayList(); //declare and create array "admis" 

void setup() {
  size(800, 600, P2D);
  smooth();

  // Create interactive map centered around Jeju
  map = new UnfoldingMap(this, new OpenStreetMap.OpenStreetMapProvider());
  map.zoomAndPanTo(10, new Location(33.35, 126.52));
  MapUtils.createDefaultEventDispatcher(this, map);
  map.setTweening(true);

  // Load CSV data
  Table DataCSV = loadTable("time_201303.csv", "header");
  for (TableRow Row : DataCSV.rows()) {
    // Create new empty object to store data
    Position container = new Position();
    // Read data from CSV
    float lat = Row.getFloat("Y_COORD");
    float lng = Row.getFloat("X_COORD");
    container.location = new Location(lat, lng);
    // Add to list of all bike stations
    admins.add(container);
}
}

void draw() {
  // Draw map and darken it a bit
  map.draw();
  fill(0, 150);
  rect(0, 0, width, height);

  noStroke();

  // Iterate over all admins
  for (Position b : admins) {
    // Convert geo locations to screen positions
    ScreenPosition pos = map.getScreenPosition(b.location);
    fill(200, 30, 200, 50);
    ellipse(pos.x, pos.y, 20, 20);
  }
}
</code></pre>

<hr />

<p>My questions are</p>

<ol>
<li><p>what is the code structure which enables me to read data over time? 
(read right direction first, and downward direction in the table above)
what is the code structure which enables me to display data over time?</p></li>
<li><p>Can I make this code simpler</p></li>
</ol>

<p>plz help me ㅜㅜ</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/035/10GEIJUXN3P1.jpg" alt="Picture1" title="Picture1" />
<img src="https://forum.processing.org/two/uploads/imageupload/179/JZKDL0W1D078.jpg" alt="Picture2" title="Picture2" />
<img src="https://forum.processing.org/two/uploads/imageupload/307/QBFDCGZZ3ZND.jpg" alt="Picture3" title="Picture3" />
<img src="https://forum.processing.org/two/uploads/imageupload/834/0VPV7NDM0IIB.jpg" alt="Picture4" title="Picture4" />
<img src="https://forum.processing.org/two/uploads/imageupload/731/NMW4XLQMKJJH.jpg" alt="Picture5" title="Picture5" />
<img src="https://forum.processing.org/two/uploads/imageupload/321/EGZCC0IROEA6.jpg" alt="Picture6" title="Picture6" />
<img src="https://forum.processing.org/two/uploads/imageupload/278/NCTRLN5XB5K2.jpg" alt="Picture7" title="Picture7" />
<img src="https://forum.processing.org/two/uploads/imageupload/076/LPUD8QG0J6NT.jpg" alt="Picture8" title="Picture8" />
<img src="https://forum.processing.org/two/uploads/imageupload/547/TGXRIUW8HRWZ.jpg" alt="Picture9" title="Picture9" />
<img src="https://forum.processing.org/two/uploads/imageupload/139/4NHHGPT1HMNQ.jpg" alt="Picture10" title="Picture10" />
<img src="https://forum.processing.org/two/uploads/imageupload/293/BMCTXMZSHDNZ.jpg" alt="Picture11" title="Picture11" />
<img src="https://forum.processing.org/two/uploads/imageupload/466/X6FPIEP1E60T.jpg" alt="Picture12" title="Picture12" />
<img src="https://forum.processing.org/two/uploads/imageupload/027/OS7YJNQBU85J.jpg" alt="Picture13" title="Picture13" /></p>
]]></description>
   </item>
   <item>
      <title>How can I create a sequence of images from a table of data ?</title>
      <link>https://forum.processing.org/two/discussion/25888/how-can-i-create-a-sequence-of-images-from-a-table-of-data</link>
      <pubDate>Tue, 09 Jan 2018 20:10:50 +0000</pubDate>
      <dc:creator>bushy_top</dc:creator>
      <guid isPermaLink="false">25888@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>This is my very first sketch. I want to create a map using data. My data consists of x/y coordinates, and to each coordinate is associated a bubble. For now, I am able to load the data and to display it like a single image:</p>

<pre><code>// The data from the Table object will fill the array of Bubble objects
Table table;
Bubble[] bubbles;

void setup() {
  size(1920, 1080);
  smooth(100);
  loadData();
}

void draw() {
  background(0);
  // Display all bubbles
  for (int i = 0; i&lt;bubbles.length; i++) {
    bubbles[i].display();
  }
}

void loadData() {
  // "header" indicates the file has header row. The size of the array 
  // is then determined by the number of rows in the table. 
  table = loadTable("jump_jump.csv", "header");
  bubbles = new Bubble[table.getRowCount()];


  for (int i = 0; i&lt;table.getRowCount(); i++) {
    // Iterate over all the rows in a table.
    TableRow row = table.getRow(i);


    // Access the fields via their column name (or index).
    float x = row.getFloat("x");
    float y = row.getFloat("y");
    float d = row.getFloat("diameter");
    // Make a Bubble object out of the data from each row.
    bubbles[i] = new Bubble(x, y, d);
  }
}



class Bubble {
  float x, y;
  float diameter;
  String name;

  boolean over = false;

  // Create the Bubble
  Bubble(float tempX, float tempY, float tempD) {
    x = tempX;
    y = tempY;
    diameter = tempD;

  }

  // Display the Bubble
  void display() {
    stroke(255);
    strokeWeight(3);
    fill(255);
    ellipse(x, y, diameter, diameter);
    }
  } 
</code></pre>

<p>But I'd like the bubbles to appear one after the other. I looked into the reference and found this scheme: goo.gl/8wfEak</p>

<pre><code>PImage[] images = new PImage[20]; // Supposing we have 20 images
int counter; // Automatically initialized at 0
final int DISPLAY_TIME = 2000; // 2000 ms = 2 seconds
int lastTime; // When the current image was first displayed

void setup()
{
  size(500, 500);

  for (int i = 0; i &lt; images.length; i++)
  {
    images[i] = loadImage("img" + nf(i+1, 2) + ".png"); // nf() allows to generate 01, 02, etc.
  }
  lastTime = millis();
}

void draw()
{
  background(255);
  fill(#005599);
  text(frameCount, 10, 20); // Shows the sketch isn't stopped between each image

  if (millis() - lastTime &gt;= DISPLAY_TIME) // Time to display next image
  {
    // Increment counter, then compute its modulo, ie. reset it at zero when reaching images.length
    counter = ++counter % images.length;
    lastTime = millis();
  }
  image(images[counter], 50, 50);
}
</code></pre>

<p>Here is my attempt at mixing both codes:</p>

<pre><code>Table table;
Bubble[] bubbles = new Bubble[200];
int counter; // Automatically initialized at 0
final int DISPLAY_TIME = 10000; // 10000 ms = 10 seconds
int lastTime; // When the current image was first displayed

void setup() {
  size(1920, 1080);
  loadData();
  // Display all bubbles
  for (int i = 0; i&lt;bubbles.length; i++) {
    bubbles[i].display();
  }
  lastTime = millis();
}

void draw() {

{
  background(0);
  text(frameCount, 10, 20);
  if (millis() - lastTime &gt;= DISPLAY_TIME) // Time to display next image
  {
    // Increment counter, then compute its modulo, ie. reset it at zero when reaching images.length
    counter = ++counter % bubbles.length;
    lastTime = millis();
  }
}
}
void loadData() {
  table = loadTable("jump_jump.csv", "header");
  bubbles = new Bubble[table.getRowCount()];

  for (int i = 0; i&lt;table.getRowCount(); i++) {
    // Iterate over all the rows in a table.
    TableRow row = table.getRow(i);

    // Access the fields via their column name (or index).
    float x = row.getFloat("x");
    float y = row.getFloat("y");
    float d = row.getFloat("diameter");
    // Make a Bubble object out of the data from each row.
    bubbles[i] = new Bubble(x, y, d);
  }
}

class Bubble {
  float x, y;
  float diameter;
  String name;
  // Create the Bubble
  Bubble(float tempX, float tempY, float tempD) {
    x = tempX;
    y = tempY;
    diameter = tempD;
  }
  // Display the Bubble
  void display() {
    stroke(255);
    strokeWeight(3);
    fill(255);
    ellipse(x, y, diameter, diameter);
  }
}
</code></pre>

<p>I tried to replace Images by bubbles but I feel like I'm confusing classes and mixing steps.
How should I do in order to make the bubbles appear one after the other ?</p>

<p>Thanks for reading !</p>
]]></description>
   </item>
   <item>
      <title>p5.js. input clearing issue</title>
      <link>https://forum.processing.org/two/discussion/25713/p5-js-input-clearing-issue</link>
      <pubDate>Mon, 25 Dec 2017 20:02:49 +0000</pubDate>
      <dc:creator>garystil</dc:creator>
      <guid isPermaLink="false">25713@/two/discussions</guid>
      <description><![CDATA[<p>Using the p5.js web editor, I have a problem clearing previously selected row values of an uploaded table. Each time I input a new row number, the sketch applies data from the newly selected row as well as from the previously selected row(s). A steady alert tone also occasionally sounds but I can't identify its source.</p>

<p>I've tried inserting clear(0, background() and redraw() at various spots but without any affect. Would be most grateful if somebody could take a look at the code I posted below and point me in the right direction. Thanks in advance.</p>

<pre><code>var table;

function preload() {
  table = loadTable("data.csv", "csv");

  // the "data.csv" file has 4 rows and 5 columns as follows:

  // 0,100,200,300,400,
  // 25,125,225,325,425,
  // 50,150,250,350,450,
  // 75,175,275,375,475,
}

function setup() {
  createCanvas(500, 300);
  background(255);

  input = createInput();
  input.position(20, 340);
  button = createButton('submit');
  button.position(input.x + input.width + 5, 340);
  greeting = createElement('b4', 'input row number (0, 1, 2 or 3 then click submit');
  greeting.position(20, 370);
  button.mousePressed(draw2);
}

function draw() {
  line(0, 0.5 * height, width, 0.5 * height);
}

function draw2() {
 var R = input.value();
 for (var i = 0; i &lt;= 4; i++) {
    ellipse(table.getNum(R, i), 0.5 * height, 10, 10);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Can not clear previously input values without re-clicking the play button.</title>
      <link>https://forum.processing.org/two/discussion/25742/can-not-clear-previously-input-values-without-re-clicking-the-play-button</link>
      <pubDate>Thu, 28 Dec 2017 20:07:10 +0000</pubDate>
      <dc:creator>angelique</dc:creator>
      <guid isPermaLink="false">25742@/two/discussions</guid>
      <description><![CDATA[<p>p5.js web editor on MacOS v. 10.12.6</p>

<p>Each time I input a value and click the submit button the canvas displays data from the previously selected row(s) as well as the newly selected row. Tried inserting clear(0, background() and redraw() at various places within the draw2() function but without any affect.</p>

<p>Is it possible to clear previously input values without re-clicking the play button? (Note: the "Input and Button" example within p5 Reference does not attempt to do this.) Thnx.</p>

<pre><code>var table;

function preload() {
  table = loadTable("data.csv", "csv");
  // the data.csv file has 4 rows and 5 column as follows:
  // 0,100,200,300,400,
  // 25,125,225,325,425,
  // 50,150,250,350,450,
  // 75,175,275,375,475,
}

function setup() {
  createCanvas(500, 300);
  background(255);

  input = createInput();
  input.position(20, 340);
  button = createButton('submit');
  button.position(input.x + input.width + 5, 340);
  greeting = createElement('b4', 'please input row number (0, 1, 2 or 3) then click submit');
  greeting.position(20, 370);
  button.mousePressed(draw2);
}

function draw() {
  line(0, 0.5 * height, width, 0.5 * height);
}

function draw2() {
  for (var i = 0; i &lt;= 5; i++) {
    var R = input.value();
    ellipse(table.getNum(R, i), 0.5 * height, 10, 10);
  }
//clear();
//background();
//redraw();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Add a color map to temperature values and plot them across the canvas as a continuous animation.</title>
      <link>https://forum.processing.org/two/discussion/25408/add-a-color-map-to-temperature-values-and-plot-them-across-the-canvas-as-a-continuous-animation</link>
      <pubDate>Wed, 06 Dec 2017 02:44:11 +0000</pubDate>
      <dc:creator>n_renier</dc:creator>
      <guid isPermaLink="false">25408@/two/discussions</guid>
      <description><![CDATA[<p>Hello Processing,</p>

<p>I'm new to processing/coding in general and am trying to figure out how to run through my data set of temperature values at 17 different longitudes for consecutive years and draw them as an animation over time.</p>

<p>I have loaded my .csv file as a table and created temp. variables at 17 locations. I would like to use the inferno colormap seen <a rel="nofollow" href="http://bids.github.io/colormap/">HERE</a>.</p>

<p>**
Here is the code I've been working with:**</p>

<pre><code>   Table table;
   int year[];
   float t1[];
   float t2[];
   float t3[];
   float t4[];
   float t5[];
   float t6[];
   float t7[];
   float t8[];
   float t9[];
   float t10[];
   float t11[];
   float t12[];
   float t13[];
   float t14[];
   float t15[];
   float t16[];
   float t17[];

   void setup() {

   size(384,270);

     table = loadTable("MyData.csv", "header");
     year = new int[table.getRowCount()];
     t1 = new float[table.getRowCount()];
     t2 = new float[table.getRowCount()];
     t3 = new float[table.getRowCount()];
     t4 = new float[table.getRowCount()];
     t5 = new float[table.getRowCount()];
     t6 = new float[table.getRowCount()]; 
     t7 = new float[table.getRowCount()];
     t8 = new float[table.getRowCount()];
     t9 = new float[table.getRowCount()];
     t10 = new float[table.getRowCount()];
     t11 = new float[table.getRowCount()];
     t12 = new float[table.getRowCount()];
     t13 = new float[table.getRowCount()];
     t14 = new float[table.getRowCount()];
     t15 = new float[table.getRowCount()];
     t16 = new float[table.getRowCount()];
     t17 = new float[table.getRowCount()];
   }
   void draw() {
     background(0);

     for (int i=0; i&lt;table.getRowCount(); i++) {
       year[i] = table.getRow(i).getInt("YEAR");
       t1[i] = table.getRow(i).getFloat("t1");
       t2[i] = table.getRow(i).getFloat("t2");
       t3[i] = table.getRow(i).getFloat("t3");
       t4[i] = table.getRow(i).getFloat("t4");
       t5[i] = table.getRow(i).getFloat("t5");
       t6[i] = table.getRow(i).getFloat("t6");
       t7[i] = table.getRow(i).getFloat("t7");
       t8[i] = table.getRow(i).getFloat("t8");
       t9[i] = table.getRow(i).getFloat("t9");
       t10[i] = table.getRow(i).getFloat("t10");
       t11[i] = table.getRow(i).getFloat("t11");
       t12[i] = table.getRow(i).getFloat("t12");
       t13[i] = table.getRow(i).getFloat("t13");
       t14[i] = table.getRow(i).getFloat("t14");
       t15[i] = table.getRow(i).getFloat("t15");
       t16[i] = table.getRow(i).getFloat("t16");
       t17[i] = table.getRow(i).getFloat("t17");
println(year[i] + ": " + t1[i] + ", " + t2[i] + ", "  + t3[i]+ "," + t4[i] + ", " + t5[i] + ", "  + t6[i]+ "," + t7[i] + ", " + t8[i] + ", "  + t9[i]+ "," + t10[i] + ", " + t11[i] + ", "  + t12[i] + "," + t13[i] + "," + t14[i] + "," + t15[i] + "," + t16[i] + "," + t17[i]) ;

 }

 }
</code></pre>

<p>Any help is greatly appreciated.</p>
]]></description>
   </item>
   <item>
      <title>Backpropagation problems (Neural network)</title>
      <link>https://forum.processing.org/two/discussion/25307/backpropagation-problems-neural-network</link>
      <pubDate>Thu, 30 Nov 2017 17:33:20 +0000</pubDate>
      <dc:creator>Trilobyte</dc:creator>
      <guid isPermaLink="false">25307@/two/discussions</guid>
      <description><![CDATA[<p>Hello all,
I am working on creating a neural network template (users can determine # of layers and # neurons/layer) and I am currently using the MNIST database to test it. There is one thing wrong, however. The last set of connections (the ones that lead to the output) have consistently all approached a value of 0.5, making all the calculations made in the previous layers moot. This problem leads to every part of the network working except for the last set of connections and output neurons. Since the equation for error sensitivity is different for the last set of connections, I assumed that was the problem, but I have checked it and I think that it should work correctly. The code is a bit messy, so feel free to ask me to clarify what any section of the code means. I have a feeling the problem is in the Train method (lines 257-310). The program is intensive, so if you run it to test it (which I highly recommend) I would use a capable computer. Macbook Airs simply do not cut it, unfortunately. Also, use the MNIST database found at <a href="https://pjreddie.com/projects/mnist-in-csv/" target="_blank" rel="nofollow">https://pjreddie.com/projects/mnist-in-csv/</a> (thanks, Dinoswarleafs).</p>

<pre><code>import java.lang.Math.*;

int[] numNs;
Brain b;
ArrayList&lt;NeuronDisplay[]&gt; nDisplay;
ArrayList&lt;Neuron[]&gt; NeuronsToMap = new ArrayList&lt;Neuron[]&gt;();

Table trainReader;
Table testReader;
//TableRow csvRow;
int counter = 0;


TableRow csvRow;


int pixelSize = 6;

float[][] expectedValues;

float[][] trainingData;

void setup() {
  size(1000, 800);
  nDisplay = new ArrayList&lt;NeuronDisplay[]&gt;();
  int[] numNeurons = {784, 26, 16, 10};
  trainReader = loadTable("mnist_train.csv");
  testReader = loadTable("mnist_test.csv");


  //int[] numNeurons = new int[int(random(3, 10))];
  //for(int i = 0; i&lt;numNeurons.length; i++){ numNeurons[i] = int(random(2, 10));}

  numNs = numNeurons;
  b = new Brain(numNs);

  float[][] ex = new float[trainReader.getRowCount()][10];
  for (int i = 0; i&lt; trainReader.getRowCount(); i++) {
    for (int j = 0; j&lt; 10; j++) {
      if (j == trainReader.getInt(i, 0)) ex[i][j] =1;
      else ex[i][j] = 0;
    }
  }
  expectedValues = ex;

  float[][] train = new float[trainReader.getRowCount()][trainReader.getColumnCount()-1];
  for (int i = 0; i&lt; train.length; i++) {
    for (int j = 1; j&lt; train[0].length; j++) {
      train[i][j] = trainReader.getInt(i, j);
    }
  }

  trainingData = train;
  // b.train(ex);
}


void draw() {
  background(#FF820D);
  strokeWeight(1);
  //pushMatrix();
  displayNet();
  // popMatrix();
  //ud();
  //  if (mousePressed) ud();
  if (counter &lt; 60000) {
    ud(counter);
    counter ++;
  } else println("-----~~~~~DONE~~~~~-----");

  if (counter &lt; 60000) {
    csvRow = trainReader.getRow(counter);
    pushMatrix();
    for (int i = 0; i &lt; trainReader.getColumnCount(); i++) {
      fill(csvRow.getInt(i));
      noStroke();
      rectMode(CENTER);

      rect(pixelSize * (i % 28) + 600, pixelSize * (i / 28) + 200, pixelSize, pixelSize);
      textAlign(CENTER);
      stroke(255);
      textSize(20);
      fill(255);
      text(trainReader.getInt(counter, 0), 650, 400);
    }
    popMatrix();
  }
} 

//void mouseClicked(){
// ud(); 
//}

void ud(int wh) {


  float[][] corresponding = expectedValues;

  Neuron[] n = new Neuron[numNs[0]];

  //  int which = int(random(trainingData.length));
  int which = wh;

  for (int i = 0; i&lt; n.length; i++) {
    n[i] = new Neuron(trainingData[which][i]);
  }

  b.updateInputs(n);
  b.update();


  float[] corr = new float[numNs[numNs.length-1]];

  corr = corresponding[which];

  b.train(corr);
  println("done");
}

class Brain {

  int[] layerSizes;
  ArrayList&lt;Neuron[]&gt; netLayers = new ArrayList&lt;Neuron[]&gt;();
  ArrayList&lt;Connection[][]&gt; connections = new ArrayList&lt;Connection[][]&gt;();

  public Brain(int[] layers) {

    layerSizes = layers;

    for (int i = 0; i&lt; layers.length; i ++) {
      // println(layers[i]);
      netLayers.add(new Neuron[layers[i]]);
    }

    for (int i = 0; i&lt; netLayers.size(); i++) {
      // NeuronDisplay[] ns = new NeuronDisplay[netLayers.get(i).length];

      for (int j = 0; j&lt; netLayers.get(i).length; j++) {
        //ns[j] = new NeuronDisplay((i * 100 + 100), (j*60 + 100), i, j);
        netLayers.get(i)[j]= new Neuron(0);
      }
      //  nDisplay.add(ns);
    }

    NeuronsToMap = netLayers;

    Neuron[] inputs = new Neuron[layers[0]];    
    //  println(inputs.length);

    for (int i = 0; i&lt; inputs.length; i++) {
      inputs[i] = new Neuron(random(0, 1));
    }

    updateInputs(inputs);

    for (int i = 1; i&lt; layers.length; i++) {
      connections.add(randomWeights(layers[i-1], layers[i]));
    }

    for (int i = 0; i&lt; netLayers.size(); i++) {
      // println();
      // printArray(netLayers.get(i));
      for (int j = 0; j&lt; netLayers.get(i).length; j++) {
        //   println(netLayers.get(i)[j].input);
      }

      // println("___");
    }

    update();

    for (int i = 0; i&lt; connections.size(); i++) {
      Connection[][] holder = connections.get(i);     
      for (int j = 0; j&lt; holder.length; j++) {
        for (int k = 0; k&lt; holder[j].length; k++) {
          //     println("which: " + i + " ["+ j + "][" + k + "] " + holder[j][k].weight);
        }
      }
    } 

    for (int i = 0; i&lt; netLayers.size(); i++) {
      //   println();
      for (int j = 0; j&lt; netLayers.get(i).length; j++) {
        //    println("| Layer: " + i + " | Neuron : " + j + " | Value: " + netLayers.get(i)[j].output);
      }
      // printArray(netLayers.get(i));
    }

    for (int k = 0; k&lt; netLayers.size(); k++) {
      NeuronDisplay[] ns = new NeuronDisplay[netLayers.get(k).length];

      for (int j = 0; j&lt; ns.length; j++) {
        ns[j] = new NeuronDisplay((k * 100 + 100), (j*60 + 100), k, j);
        //  netLayers.get(i)[j]= new Neuron();
      }

      nDisplay.add(ns);
    }
  }

  public Connection[][] randomWeights(int r, int c) {

    Connection[][] ret = new Connection[r][c];

    for (int i = 0; i&lt; r; i++) {
      for (int j =0; j&lt; c; j++) {
        ret[i][j] = new Connection(random(-1, 1));
      }
    }

    return ret;
  }

  void updateWeights(int which, Connection[][] change) {    
    connections.set(which, change);
  }

  Neuron[] retInputs() {
    return netLayers.get(0);
  }

  Neuron[] retOutputs() {
    return netLayers.get(netLayers.size()-1);
  }

  int[] retLayerNums() {
    return layerSizes;
  }

  void updateInputs(Neuron[] in) {   
    netLayers.set(0, in);
  }

  void update() {

    for (int i = 0; i&lt; netLayers.size()-1; i++) {
      //  float[] ret = new float[netLayers.get(i+1).length];
      Neuron[] layer1 = netLayers.get(i);
      Neuron[] nextLayer = new Neuron[netLayers.get(i+1).length];

      Connection[][] conns = connections.get(i);

      for (int j = 0; j&lt; netLayers.get(i+1).length; j++) {
        nextLayer[j] = new Neuron(0);
        for (int k = 0; k&lt; layer1.length; k++) {
          nextLayer[j].input += layer1[k].output * conns[k][j].weight;
        }
        nextLayer[j].activate();
        //nextLayer[j].carry();
        // else nextLayer[j].activate();
      }
      netLayers.set(i+1, nextLayer);
    }
    NeuronsToMap = netLayers;
  }  

  void train(float[] expect) {

    //float[] errors = new float[netLayers.get(netLayers.size()-1).length];
    float[] expected = expect;

    //float[][] errorSensitivities = ;
    // float totalError = 0;
    float learningRate = .1;

    for (int l = netLayers.size()-1; l&gt;= 0; l--) { 
      Neuron[] outputNeurons = netLayers.get(l);      
      for (int j = 0; j&lt; netLayers.get(l).length; j++) {
        if (l &gt;= netLayers.size() -1) {
          netLayers.get(l)[j].dC_dAj = 2*(outputNeurons[j].output - expected[j]);
        } else {
          for (int p = 0; p&lt; netLayers.get(l+1).length; p++) {
            //  println(netLayers.size(), " ", l, " ", netLayers.get(l).length, " ", j, "  ", p);
            netLayers.get(l)[j].dC_dAj += connections.get(l)[j][p].weight * ((1/(1+ exp(-(netLayers.get(l+1)[p].input))))
              *(1-(1/(1+ exp(-(netLayers.get(l+1)[p].input)))))) * netLayers.get(l+1)[p].dC_dAj;
          }
        }
      }
    }

    for (int n = 0; n&lt;netLayers.size()-1; n++) {
      //   println(netLayers.size(), " ", n);
      //   Neuron[] outputNeurons = netLayers.get(n+1);
      Connection[][] layerN = connections.get(n);  
      Neuron[] previous  = netLayers.get(n);

      for (int i = 0; i&lt;layerN.length; i++) {
        for (int j = 0; j&lt; layerN[i].length; j++) { 
          //println(netLayers.size(), " ", outC.length, " ", outC[i].length, " ", n, " ", i, " ", j);
          //connections.get(n)[i][j].updateSensitivity(1);
          connections.get(n)[i][j].updateSensitivity(previous[i].output * ((1/(1+ exp(-(netLayers.get(n+1)[j].input)))) *
            (1-(1/(1+ exp(-(netLayers.get(n+1)[j].input)))))) * netLayers.get(n+1)[j].dC_dAj);
        }
      }
    }

    for (int i = 0; i&lt; connections.size(); i++) {
      Connection[][] ret = new Connection[connections.get(i).length][connections.get(i)[0].length];
      for (int j = 0; j&lt; connections.get(i).length; j++) {
        for (int k = 0; k&lt; connections.get(i)[j].length; k++) {
          float newWeight = connections.get(i)[j][k].weight - learningRate * connections.get(i)[j][k].errorSensitivity * connections.get(i)[j][k].weight;
          //println( connections.get(i)[j][k].errorSensitivity);

          ret[j][k]= new Connection(newWeight);
        }
      } 
      connections.set(i, ret);
    }
  } // end train()
}

class Connection {

  float errorSensitivity;
  float weight;
  float learningRate = .01;
  float fill;

  public Connection(float weight) {
    this.weight = weight;
    this.errorSensitivity = 0;
    fill = map(weight, -1, 1, 0, 255);
  }

  void updateWeight() {
    // weight = weight - learningRate*(errorSensitivity);
    weight = random(-1, 1);
    fill = map(weight, -1, 1, 0, 255);
  }

  void updateSensitivity(float in) {

    errorSensitivity = in;
  }
}

class Neuron {

  public float input = -10; // weighted input into neuron
  float output = -10; //activated output
  float bias;
  float fill = 255;
  float dC_dAj = 0;

  //public Neuron() {
  //  input = 0;
  //  output = 0;
  //  bias = 0;
  //  fill = int(map(input, 0, 1, 0, 255));

  //}

  public Neuron(float input) {
    this.input = input;
    this.output = input;
    bias = 0;
    fill = int(map(input, 0, 1, 0, 255));
  }

  void updateInput(float in) {
    input = in;
  }

  void updateBias(float in) {
    bias = in;
  }

  void activate() {        
    // output = (float)Math.tanh(input);    
    // output = 1/(1+e^(-input))
    output = 1/(1+ exp(-(input-bias)));
    //    println(output);
    fill = int(map(output, 0, 1, 0, 255));
  }

  void isInput() {
    output = input;
  }
  void carry() {
    output = input;
  }
}

class NeuronDisplay {

  int x, y;
  float size = 30;
  int layer, position;
  int fill;

  public NeuronDisplay(int x, int y, int whichLayer, int whichNeuron) {   
    this.x = x;
    this.y = y;
    this.layer = whichLayer;
    this.position = whichNeuron;
  }

  void display() {
    // println("netLayers size: " + b.netLayers.size(), " ", layer, " ", b.netLayers.get(layer).length + " " + position);
    if (layer&lt;b.netLayers.size() &amp;&amp; position &lt; b.netLayers.get(layer).length)  fill(b.netLayers.get(layer)[position].fill);
    else fill(255, 0, 0);
    ellipse(x, y, size, size);
  }
}

void displayNet() {

  for (int i = 0; i&lt; nDisplay.size()-1; i++) {
    NeuronDisplay[] hold = nDisplay.get(i);
    NeuronDisplay[] next = nDisplay.get(i+1);

    for (int j = 0; j&lt; hold.length; j++) {
      for (int k = 0; k&lt;next.length; k++) {
        stroke(b.connections.get(i)[j][k].fill);
        line(hold[j].x, hold[j].y, next[k].x, next[k].y);
      }
    }
  }

  for (int i = 0; i&lt; nDisplay.size(); i++) {
    //  NeuronDisplay[] hold = nDisplay.get(i);
    for (int j = 0; j&lt; nDisplay.get(i).length; j++) {
      stroke(255);
      nDisplay.get(i)[j].display();
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to gather mapped data into a float array?</title>
      <link>https://forum.processing.org/two/discussion/25169/how-to-gather-mapped-data-into-a-float-array</link>
      <pubDate>Thu, 23 Nov 2017 18:38:09 +0000</pubDate>
      <dc:creator>mfuster</dc:creator>
      <guid isPermaLink="false">25169@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I've been banging my head against the wall with this one for a few days as my knowledge of Processing is next to null.
I have a csv with Lux measurements. I am trying to retrieve the lux data and map it so that I can use it as an 'alpha' property in a rect() fill.
I'm sure it's really simple but I just don't know where I am going wrong.
This is my code:</p>

<pre><code>Table table;
float [] luxValues;
float luxMapped;
float [] alpha;
int margin, graphHeight;
float overallMin, overallMax;
int RowCount;


void setup () {
  size(1200, 300);
  processData();
}

void draw () {
  background(20);

  for (int i=0; i&lt;60; i++) {
    //fill(255,alpha);
    stroke(255);
    rect(margin+i*10, margin, 10, 10);
  }
  for (int i=61; i&gt;60 &amp;&amp; i&lt;RowCount; i++) {
    //fill(255,alpha);
    stroke(255);
    rect(margin+(i-61)*10, margin+10, 10, 10);
  }
}


void processData() {
  table=loadTable("040617.csv", "header");
  RowCount = table.getRowCount();
  float[] luxValues = float(table.getStringColumn("lux"));
  overallMin = min(luxValues);
  overallMax = max(luxValues);

  margin = 50;

 for (int i=0; i&lt;RowCount; i++) {
    float luxMapped = map(luxValues[i], overallMin, overallMax, 0, 255);

    // need to map luxValues onto a luxAlpha array here?
    //float[] alpha = luxMapped;??
  }
}
</code></pre>

<p>Any help or suggestions appreciated. Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Reading .CSV file and displaying visuals in accordance with the data</title>
      <link>https://forum.processing.org/two/discussion/24685/reading-csv-file-and-displaying-visuals-in-accordance-with-the-data</link>
      <pubDate>Sun, 22 Oct 2017 02:08:33 +0000</pubDate>
      <dc:creator>MeganCodey</dc:creator>
      <guid isPermaLink="false">24685@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone,</p>

<p>I have a spreadsheet with the first 1 million numbers in PI.
The goal is to have different visuals displayed along with music tones in accordance with the numbers in the chart (0-9).
The sound works, however I cannot get the program to show any visuals at the same time.
Eg. I want the program to draw an ellipse whenever "0" is read from the .CSV file.</p>

<p>Here is my code:</p>

<pre><code>Table data;
int[] row; 

import ddf.minim.*;

Minim minim;

AudioPlayer DO;
AudioPlayer RE;
AudioPlayer MI;
AudioPlayer FA;
AudioPlayer SOL;
AudioPlayer LA;
AudioPlayer TI;
AudioPlayer DOO;

void setup() {
  size(500, 500);
  background(50);
  minim = new Minim(this);
  data = loadTable("pi.csv", "header");

  DO = minim.loadFile("do.wav");
  RE = minim.loadFile("re.wav");
  MI = minim.loadFile("mi.wav");
  FA = minim.loadFile("fa.wav");
  SOL = minim.loadFile("sol.wav");
  LA = minim.loadFile("la.wav");
  TI = minim.loadFile("ti-WAV.wav");
  DOO = minim.loadFile("do-octave.wav");
}

void draw() {
  fill(250);
  stroke(250);


  row = new int[ data.getRowCount()]; //create an array for row


  for (TableRow row : data.rows()) {
    for (int i=0; i &lt; 10; i++) { // for loop with an increasing "i" allows program go get info through the rows
      int A = row.getInt(i);  //intA is equal to the number in the row

      delay(200);
      ellipse(mouseX, mouseY, 100, 50);

      if (A==0) {
        delay(500);
        ellipse(100, 100, 100, 50);
      }

      if (A==1) {
        RE.rewind();
        RE.play();
        ellipse(200, 200, 50, 50);
      }

      if (A==2) {
        MI.rewind();
        MI.play();
      }

      if (A==3) {
        FA.rewind();
        FA.play();
      }

      if (A==4) {
        SOL.rewind();
        SOL.play();
      }

      if (A==5) {
        LA.rewind();
        LA.play();
      }
      if (A==6) {
        TI.rewind();
        TI.play();
      }
      if (A==7) {
        DOO.rewind();
        DOO.play();
      }
      if (A==8) {
        delay(300);
      }

      if (A==9) {
        DO.rewind();
        DO.play();
      }
    }
  }
}
</code></pre>

<p>What can I do?
Thank you!!</p>
]]></description>
   </item>
   <item>
      <title>Why isn't initializing ArrayList size working?</title>
      <link>https://forum.processing.org/two/discussion/24562/why-isn-t-initializing-arraylist-size-working</link>
      <pubDate>Sun, 15 Oct 2017 15:51:30 +0000</pubDate>
      <dc:creator>Aleksi</dc:creator>
      <guid isPermaLink="false">24562@/two/discussions</guid>
      <description><![CDATA[<p>Hi there.</p>

<p>According to the <a rel="nofollow" href="https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html#ArrayList-int-">java docs</a> I can declare an ArrayList with an initial size: <code>public ArrayList(int initialCapacity)</code></p>

<p>Yet when I execute this:</p>

<pre><code>ArrayList&lt;PVector&gt; tpv = new ArrayList&lt;PVector&gt;(2);
println("1: init tpv size: ",tpv.size());
tpv.add(new PVector());
tpv.add(new PVector());
println("2: init tpv size: ",tpv.size());
</code></pre>

<p>I get the following output:</p>

<pre><code>1: init tpv size:  0
2: init tpv size:  2
</code></pre>

<p>This is a simplified case of my ultimate goal which is trying to initialize tpv with the size of another PVector array:
 <code>ArrayList&lt;PVector&gt; tpv = new ArrayList&lt;PVector&gt;(pva.size());</code></p>

<p>Am I doing something wrong? Am I misunderstanding the javadoc? Can I declare tpv with an initial size?</p>
]]></description>
   </item>
   <item>
      <title>Visualization of commuters</title>
      <link>https://forum.processing.org/two/discussion/24547/visualization-of-commuters</link>
      <pubDate>Sat, 14 Oct 2017 16:48:09 +0000</pubDate>
      <dc:creator>Tom_lilly</dc:creator>
      <guid isPermaLink="false">24547@/two/discussions</guid>
      <description><![CDATA[<p>Hi</p>

<p>I'm very new to processing and how it works, but i want to learn how to use it for visualizing data I've collected for my university projects. I currently have data for the number of commuters that go to work outside of the town on the Isle of Wight, UK, and where they go. with this, i want to be able to produce a map similar to the maps you see of flight travel or network data but i cant find a useful source to learn from, and being a beginner with processing i can't think how to do this.
If anyone is willing to guide me in the right direction that would be great!</p>

<p>Thanks
Tom</p>
]]></description>
   </item>
   <item>
      <title>center a table in window?</title>
      <link>https://forum.processing.org/two/discussion/24522/center-a-table-in-window</link>
      <pubDate>Thu, 12 Oct 2017 17:39:59 +0000</pubDate>
      <dc:creator>JWood</dc:creator>
      <guid isPermaLink="false">24522@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to center a table in my presentation window, but I cannot find any code samples in the processing guide about table placement, just text. I am a complete noob to code so please be be patient. 
My current code:
    size(1200, 675);</p>

<pre><code>Table tabela = loadTable("cidades.tsv", "header");
for (int i = 0; 
  i &lt; tabela.getRowCount(); 
  i = i + 1) {
  TableRow linha = tabela.getRow(i);
  int posX = 100*i;
  int posY = 405;
  float lado = sqrt(linha.getInt("área"));
  ellipse(posX, posY, lado, lado);
  for (int j=0; 
    j&lt;linha.getInt("população")/5000; 
    j=j+1) {
    point(random(posX - lado, posX + lado), 
      random(posY - lado, posY+lado));
  }
}
</code></pre>

<p>The data I am pulling from the .tsv:
            cidade  população   área
            Tokyo-Yokohama  37239000    8547
            Jakarta (Jabotabek) 26746000    2784
            Seoul-Incheon   22868000    2163
            Delhi, DL-HR-UP 22826000    1943
            Shanghai, SHG   21766000    3497
            Manila  21241000    1437
            Karachi 20877000    803
            New York, NY-NJ-CT  20673000    11642
            Sao Paulo   20568000    3173
            Mexico City 20032000    2046</p>
]]></description>
   </item>
   <item>
      <title>The table has no column named '' ''</title>
      <link>https://forum.processing.org/two/discussion/24337/the-table-has-no-column-named</link>
      <pubDate>Mon, 02 Oct 2017 03:14:40 +0000</pubDate>
      <dc:creator>dodateodora</dc:creator>
      <guid isPermaLink="false">24337@/two/discussions</guid>
      <description><![CDATA[<p>I just started out in Processing and need to create an interactive data visualization as my main assignment. I'm having a lot of trouble since the teacher won't help us,and the data I put into my program works fine,but it keeps saying that the table has no column named ''MovieTitle'' even though I know it does. It is the very first cell in my Excel file,and I've already checked for any spaces that I might have missed - nothing. If anyone could help me with this and some other things,it would be greatly appreciated!</p>
]]></description>
   </item>
   <item>
      <title>Mouse clicking and database questions?</title>
      <link>https://forum.processing.org/two/discussion/24133/mouse-clicking-and-database-questions</link>
      <pubDate>Sat, 16 Sep 2017 03:19:10 +0000</pubDate>
      <dc:creator>ImJaz</dc:creator>
      <guid isPermaLink="false">24133@/two/discussions</guid>
      <description><![CDATA[<p>Hi there! 
I've spent a long time trying to figure out how I can get my database and my mouse clicks to work. If someone could help me with it I would appreciate it so much. What I want to do is get the buttons on the side to individually have their own information from the database. When I use my mouse click command it goes on all three of the buttons but I want it to only work on one each. When you click on a button I wanted it to grab something from the database I've made so the first button would be the first bit in my database then where the database is spaced, that's for the second button. I'm quite confused on how to do this and my video is now not working as well (it's meant to tint to the jellyfish and it). If someone could help it would be great!</p>

<p><a href="http://alpha.editor.p5js.org/Jaz/sketches/rkNRPAuqb" target="_blank" rel="nofollow">http://alpha.editor.p5js.org/Jaz/sketches/rkNRPAuqb</a></p>
]]></description>
   </item>
   <item>
      <title>How to create a bar-chart where the "table.sort" change on request with a button!</title>
      <link>https://forum.processing.org/two/discussion/23993/how-to-create-a-bar-chart-where-the-table-sort-change-on-request-with-a-button</link>
      <pubDate>Fri, 01 Sep 2017 13:48:18 +0000</pubDate>
      <dc:creator>nachoman</dc:creator>
      <guid isPermaLink="false">23993@/two/discussions</guid>
      <description><![CDATA[<p>This is my first processing question for my first processing project, so sorry everybody for my ignorance of the software and of the forum rules, I'll be deeply thankful if anyone will be so kind to answer!</p>

<p>My problem is the following one:
I would like to do a bar chart representing my 100 favorite songs (according to iTunes reproductions!), where you can change the <strong>table.sort</strong>, the disposition of the song in genre, artist, n° of reproduction, etc... with some buttons to do it.
I've tried to do something with cp5 button, but the main problem is that if i maintain <strong>noLoop()</strong> the graph don't change, but if I take it away the graph goes crazy.
I report down here the code and the CSV table!</p>

<p>Help me please, free hugs and the give of my final project if you do!</p>

<p>CODE:</p>

<pre><code>import controlP5.*;

ControlP5 cp5;

Table table;
int c;
PFont font;
boolean Bottone = false;


void setup() {
  //size(800, 600);
  fullScreen();
  background(255);
  smooth();
  table = loadTable("My Music Numbers_first 100.csv", "header");
  font = createFont("Chivo-Regular-13.vlw", 13);//aggiunta la font

    cp5= new ControlP5(this); 

  cp5.addToggle("Bottone")
     .setPosition(20,180)
     .setSize(90,15)
     ;

}


void draw() {
  //questa linea e la successiva per invertire l'asse delle y
  /*scale(1, -1);
  translate(0, -height);*/

    font = createFont("CircularStd-Bold", 40);
    textFont(font);
    textSize(32);
    fill(#B0F566);
    textAlign(CENTER);
    text("My Favourite Tracks",(width/2),100);
    textSize(18);
    fill(#83B45B);
    text("A data—visualization of the 100 songs that I love most",(width/2),150);


    for (int i = 0; i&lt;table.getRowCount(); i++) {

    // Access each row of the table one at a time, in a loop.
    TableRow riga = table.getRow(i);
    int posizione = riga.getInt("posizione");
    String n = riga.getString("artista");
    String titolo = riga.getString("titolo");
    int score = riga.getInt("riproduzioni");
    int durata = riga.getInt("durata");
    String album = riga.getString("album");
    int anno = riga.getInt("anno");
    String genere = riga.getString("genere");
    String nazione = riga.getString("nazione");
    int x = 200+(i*10);
    int y = height/2;

    table.sort("riproduzioni");

     if (genere.equals("Alternativa/Indie") == true) {
      c = #B0F566;
    } 
    if (genere.equals("Reggae") == true) {
      c = #4AF2A1;
    } 
    if (genere.equals("Pop") == true) {
      c = #5CC9F5;
    } 
    if (genere.equals("Rock") == true) {
      c = #6638F0;
    }

    if (genere.equals("Hip Hop") == true) {
      c = #E8235E;
    }
    if (genere.equals("Rap") == true) {
      c = #FF1A1A;
    }
    if (genere.equals("Ska") == true) {
      c = #1EF7D1;
    }
    if (genere.equals("Dance Elettronica") == true) {
      c = #FFF41A;
    }
    if (genere.equals("Neofolk") == true) {
      c = #10FF00;
    } 
    if (genere.equals("Soul") == true) {
      c = #2420C4;
    }
    if (genere.equals("Punk") == true) {
      c = #CB7777;
    }

    if (Bottone == true) {
    table.sort("genere");

  } else {
    table.sort("riproduzioni");
  }

    fill(c);
    rectMode(CENTER);
    noStroke();
    rect(x, y, 10, score*4,7);
    //noLoop();

    println(titolo + " " + score);
  }
}
</code></pre>

<p>CSV (named "My Music Numbers_first 100.csv"):</p>

<p>posizione,artista,titolo,riproduzioni,durata,album,anno,genere,nazione
001,The Vaccines,All in White,112,04:34,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra
002,The Vaccines,Norgaard,079,01:38,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra
003,Alt-J,Dissolve Me,065,04:00,An Awesome Wave,2012,Alternativa/Indie,Inghilterra
004,Bon Iver,Skinny Love,063,03:58,For Emma| Forever Ago,2007,Alternativa/Indie,USA
005,Alt-J,Breezeblocks,058,03:47,An Awesome Wave,2012,Alternativa/Indie,Inghilterra
006,The Vaccines,Wetsuit,053,03:50,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra
007,Bob Marley &amp; The Wailers,Stir It Up,048,03:41,Catch a Fire,1973,Reggae,Inghilterra
008,The Libertines,Don't Look Back Into The Sun,048,03:21,The Libertines,2004,Alternativa/Indie,Inghilterra
009,Tame Impala,Feels Like We Only Go Backwards,047,03:13,Lonerism,2012,Alternativa/Indie,Australia
010,The Vaccines,A Lack Of Understanding,044,02:59,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra
011,Babyshambles,Maybeline,041,03:16,Sequel to the Prequel,2013,Alternativa/Indie,Inghilterra
012,Gazebo Penguins,Difetto,041,02:23,Raudo,2013,Alternativa/Indie,Italia
013,Alt-J,Matilda,041,03:48,An Awesome Wave,2012,Alternativa/Indie,Inghilterra
014,King Harvest,Dancing in the Moonlight,040,02:52,Dancing in the Moonlight,1973,Pop,USA
015,Gazebo Penguins,Finito il cafe,039,03:05,Raudo,2013,Alternativa/Indie,Italia
016,Alt-J,Something Good,038,03:42,An Awesome Wave,2012,Alternativa/Indie,Inghilterra
017,Egg,Shoe,038,03:45,Shoe EP,2009,Rock,Inghilterra
018,The Vaccines,Blow It Up,037,02:36,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra
019,I Cani,Corso Trieste,034,03:28,Glamour,2013,Pop,Italia
020,I Cani,Post Punk,034,04:46,Il sorprendente album d'esordio de i cani,2011,Pop,Italia
021,The Vaccines,Under Your Thumb,034,02:20,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra
022,Chiddy Bang,By Your Side,034,03:48,inedito,2012,Hip Hop,USA
023,Gazebo Penguins,Casa dei Miei,033,02:28,Raudo,2013,Alternativa/Indie,Italia
024,I Cani,Hipsteria,033,03:39,Il sorprendente album d'esordio de i cani,2011,Pop,Italia
025,U2,California (There Is No End to Love),033,04:00,Songs of Innocence,2014,Rock,Irlanda
026,Gazebo Penguins,Domani e' gennaio,032,02:57,Raudo,2013,Alternativa/Indie,Italia
027,Babyshambles,Fireman,031,01:42,Sequel to the Prequel,2013,Alternativa/Indie,Inghilterra
028,Babyshambles,Nothing Comes to Nothing,030,03:15,Sequel to the Prequel,2013,Alternativa/Indie,Inghilterra
029,Gazebo Penguins,Correggio,030,02:00,Raudo,2013,Alternativa/Indie,Italia
030,I Cani,Le coppie,030,03:09,Il sorprendente album d'esordio de i cani,2011,Pop,Italia
031,I Cani,Il pranzo di santo stefano,030,02:09,Il sorprendente album d'esordio de i cani,2011,Pop,Italia
032,The Vaccines,Post Break-Up Sex,030,02:54,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra
033,Babyshambles,Farmer's Daughter,028,05:05,Sequel to the Prequel,2013,Alternativa/Indie,Inghilterra
034,Gazebo Penguins,Ogni scelta e' in perdita,028,03:23,Raudo,2013,Alternativa/Indie,Italia
035,I Cani,Velleita',028,04:47,Il sorprendente album d'esordio de i cani,2011,Pop,Italia
036,Mecna,Cerotti,028,02:52,inedito,2012,Rap,Italia
037,Mighty Oaks,Brother,028,03:16,Brother,2012,Alternativa/Indie,Germania
038,The Vaccines,Tiger Blood,028,02:08,Come Of Age,2012,Alternativa/Indie,Inghilterra
039,Mecna,31/07,027,03:16,Bagagli a mano,2011,Rap,Italia
040,Paolo Nutini,10/10,027,02:57,Sunny Side Up,2009,Ska,Inghilterra
041,The Vaccines,If You Wanna,027,02:54,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra
042,U2,The Miracle (Of Joey Ramone),027,04:15,Songs of Innocence,2014,Rock,Irlanda
043,Big Sean,Too Fake,027,04:12,Finally Famous Vol. 3: Big,2010,Hip Hop,USA
044,Flume,Holdin On,027,02:35,Flume,2012,Dance Elettronica,Australia
045,Deluxe,Pony,027,03:29,Polishing Peanuts,2011,Dance Elettronica,Francia
046,Bob Marley &amp; The Wailers,One Love,026,02:53,Exodus,1977,Reggae,Giamaica
047,Drowners,Ways to Phrase a Rejection,026,01:46,Drowners,2014,Alternativa/Indie,USA
048,The Vaccines,Wreckin' Bar (Ra Ra Ra),026,01:22,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra
049,The Hives,Hate To Say I Told You So,026,03:20,Veni Vidi Vicious,2000,Alternativa/Indie,Svezia
050,Bon Iver,Holocene,025,05:36,Bon Iver| Bon Iver,2011,Alternativa/Indie,USA
051,I Cani,FBYC (Sfortuna),025,03:35,Glamour,2013,Pop,Italia
052,The Libertines,Music When The Lights Go Out,025,03:02,The Libertines,2004,Alternativa/Indie,Inghilterra
053,The Vaccines,Teenage Icon,025,03:05,Come Of Age,2012,Alternativa/Indie,Inghilterra
054,Cee Lo Green,Fuck You,025,03:54,The Lady Killer,2010,Pop,USA
055,Oscar Isaac,Hang Me| Oh Hang Me,025,03:23,Inside Llewyn Davis,2013,Neofolk,USA
056,The Tallest Man on Earth,Love is all,025,04:17,The Wild Hunt,2010,Neofolk,Svezia
057,The Vaccines,If You Wanna,025,02:54,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra
058,Bob Marley &amp; The Wailers,No Woman No Cry,024,07:12,Natty Dread,1975,Reggae,Giamaica
059,Bob Marley &amp; The Wailers,Three Little Birds,024,03:02,Exodus,1980,Reggae,Giamaica
060,Drowners,Luv| Hold Me Down,024,02:51,Drowners,2014,Alternativa/Indie,USA
061,Gazebo Penguins,Non moriro',024,02:53,Raudo,2013,Alternativa/Indie,Italia
062,The Tallest Man on Earth    ,Thousand Ways,024,02:53,The Wild Hunt,2010,Neofolk,Svezia
063,The Vaccines,No Hope,024,04:10,Come Of Age,2012,Alternativa/Indie,Inghilterra
064,The Vaccines,Wolf Pack,024,02:24,What Did You Expect From The Vaccines?,2011,Alternativa/Indie,Inghilterra
065,Justice,D.A.N.C.E. ,024,04:03,Cross,2007,Dance Elettronica,Francia
066,Arctic Monkeys,Mardy Bum,023,02:55,Whatever People Say I Am| That's What I'm Not,2006,Alternativa/Indie,Inghilterra
067,Babyshambles,New Pair,023,03:06,Sequel to the Prequel,2013,Alternativa/Indie,Australia
068,Mumford &amp; Sons,Below My Feet,023,05:00,Babel,2012,Neofolk,Inghilterra
069,Otis Redding    ,Respect,023,02:10,Otis Blue: Otis Redding Sings Soul,1965,Soul,USA
070,Grouplove,Itchin' On A Photograph,023,04:23,Never Trust a Happy Song,2011,Rock,USA
071,Ingrid Michaelson,You And I,023,02:36,Girls and Boys,2006,Alternativa/Indie,USA
072,Bob Marley &amp; The Wailers,Get Up Stand Up,022,03:20,Burnin',1973,Reggae,Giamaica
073,Drowners,Long Hair,022,01:49,Drowners,2014,Alternativa/Indie,USA
074,I Cani,Non c'e' niente di twee,022,04:04,Glamour,2013,Pop,Italia
075,I Cani,Storia di un impiegato,022,03:53,Glamour,2013,Pop,Italia
076,I Cani,I pariolini di diciott'anni,022,03:46,Il sorprendente album d'esordio de i cani,2011,Pop,Italia
077,Mumford &amp; Sons,The Cave,022,03:38,Sigh No More,2009,Neofolk,Inghilterra
078,The Tallest Man on Earth,Thrown Right at Me,022,02:59,Sometimes the Blues Is Just a Passing Bird,2010,Neofolk,Svezia
079,U2,Every Breaking Wave,022,04:12,Songs of Innocence,2014,Rock,Irlanda
080,Rancid,Ruby Soho,022,02:52,...And Out Come the Wolves,1995,Punk,USA
081,Sam Smith,Stay With Me,022,02:55,In the Lonely Hour,2014,Soul,Inghilterra
082,The Killers,Mr. Brightside,022,03:47,Hot Fuss,2004,Alternativa/Indie,USA
083,Bob Marley &amp; The Wailers,I Shot The Sheriff,021,03:54,Burnin',1973,Reggae,Giamaica
084,Chance The Rapper,Cocoa Butter Kisses ,021,05:07,Acid Rap,2013,Rap,USA
085,Coez,Lontana da me,021,03:43,Non erano fiori,2013,Pop,Italia
086,I Cani,Door Selection,021,02:40,Il sorprendente album d'esordio de i cani,2011,Pop,Italia
087,I Cani,Perdona e dimentica,021,03:37,Il sorprendente album d'esordio de i cani,2011,Pop,Italia
088,Mumford &amp; Sons,Sigh No More,021,03:28,Sigh No More,2009,Neofolk,Inghilterra
089,The Black Keys,Lonely Boy,021,03:13,El Camino,2011,Alternativa/Indie,USA
090,The Libertines,What Katie Did,021,03:50,The Libertines,2004,Alternativa/Indie,Inghilterra
091,The Vaccines,I Wish I Was A Girl,021,02:52,Come Of Age,2012,Alternativa/Indie,Inghilterra
092,The Vaccines,Bad Mood,021,03:14,Come Of Age,2012,Alternativa/Indie,Inghilterra
093,Bob Marley &amp; The Wailers,Jamming,020,03:35,Exodus,1977,Reggae,Giamaica
094,Bon Iver    ,Beth/Rest,020,06:26,Bon Iver|Bon Iver,2011,Alternativa/Indie,USA
095,Bon Iver,Minnesota|WI,020,03:32,Bon Iver|Bon Iver,2011,Alternativa/Indie,USA
096,Gazebo Penguins,Mio Nonno,020,01:47,Raudo,2013,Alternativa/Indie,Italia
097,I Cani,Come vera nabokov,020,04:03,Glamour,2013,Pop,Italia
098,Mumford &amp; Sons,Roll Away Your Stone,020,04:24,Sigh No More,2009,Neofolk,Inghilterra
099,The Black Keys,Little Black Submarines,020,04:11,El Camino,2011,Alternativa/Indie,USA
100,The Cure,Just Like Heaven,020,3:30,Kiss Me Kiss Me Kiss Me,1987,Alternativa/Inside,Inghilterra</p>
]]></description>
   </item>
   <item>
      <title>Embedding sketch in webpage(html)</title>
      <link>https://forum.processing.org/two/discussion/23452/embedding-sketch-in-webpage-html</link>
      <pubDate>Sat, 15 Jul 2017 09:33:47 +0000</pubDate>
      <dc:creator>tatertot</dc:creator>
      <guid isPermaLink="false">23452@/two/discussions</guid>
      <description><![CDATA[<p>Hello.   I am working on a sketch based on the "Solar system generator" (video link below).</p>

<p><strong></strong>
<span class="VideoWrap"><span class="Video YouTube" id="youtube-FGAwi7wpU8c"><span class="VideoPreview"><a href="http://youtube.com/watch?v=FGAwi7wpU8c"><img src="http://img.youtube.com/vi/FGAwi7wpU8c/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span></p>

<p>I modified the code such that it retrieves the number of moons and the appropriate image file from a .csv, and managed to get it working.</p>

<p>However, I have trouble embedding it to a html file. 
Below are the contents of the html and processing code.
I also attached an image of the working directory.</p>

<p>Any pointers on what's going wrong is greatly appreciated.
(I have a feeling it has something to do with the *@pjs preload command of the .pde ..., but not sure)</p>

<p>Many thanks in advance.</p>

<p>-----<strong>html code</strong>--------</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;title&gt; My first webpage&lt;/title&gt;
&lt;script src="Processing.js"&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
Hello World!
&lt;marquee&gt; this is a test!&lt;/marquee&gt;
&lt;canvas data-processing-sources="solargenerator_sunrotate_ver6.pde planet.pde"&gt;&lt;/canvas&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<hr />

<p>-----<strong>sketch code  solargenerator_sunrotate_ver6</strong>--------</p>

<pre><code>import peasy.*;
Planet[] sun;


PeasyCam cam;

PImage sunTexture;
PImage[] textures = new PImage[3];
Table holidaytable;
int nrows;

void setup() {
  size(900, 700, P3D);

  Table holidaytable=loadTable("test.csv", "header");

  textures[0] = loadImage("earth.jpg");
  textures[1] = loadImage("cmb.jpg");
  textures[2] = loadImage("sky.jpg");

  cam = new PeasyCam(this, 1000);

  int nrows =holidaytable.getRowCount(); 

  sun = new Planet[nrows];


  for (int i = 0; i &lt; nrows; i++) {
    TableRow row = holidaytable.getRow(i);

    int ID = row.getInt("no");
    int holiday = row.getInt("holidays");
    String picture = row.getString("image");

    sunTexture= loadImage(picture);

    sun[i]= new Planet(50, 450, 0, true, ID, sunTexture);
    sun[i].spawnMoons(holiday,1); 
  }  
}

void draw() {
  background(0);
  lights();

  for (Planet sun2 : sun) {
    sun2.show();
    sun2.orbit();
  }
}
</code></pre>

<hr />

<p><strong></strong>
OS: windows 10
Processing version: 3.3.4</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/330/MACC2YASK632.PNG" alt="workingdirectory" title="workingdirectory" /></p>
]]></description>
   </item>
   <item>
      <title>Program freezing when using Serial out</title>
      <link>https://forum.processing.org/two/discussion/23387/program-freezing-when-using-serial-out</link>
      <pubDate>Mon, 10 Jul 2017 11:28:59 +0000</pubDate>
      <dc:creator>eugval</dc:creator>
      <guid isPermaLink="false">23387@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys,</p>

<p>This program I've made is designed to read data from a csv file and output it to an arduino (which will in turn eventually output it to a motor). Strangely, it runs just fine without the Arduino plugged in, but with the Arduino plugged in it starts freezing every one or two seconds after the first eight seconds or so. I presume some buffer somewhere is being filled up and is not clearing itself fast enough, but I have no idea where. Any thoughts?</p>

<pre><code>/*  CSV_READER
    Version 3.4

    Improvements from last version:
    - 

    Improvements to be made:
    - Begins to freeze when Arduino plugged in

*/

import processing.serial.*;

int xpos=90; // set x servo's value to mid point (0-180);
int ypos=90; // and the same here
Serial port; // The serial port we will be using
Table table;
final int motorPulley = 17; //number of teeth on the pulley
final int enginePulley = 51;
final int calibrationFactor = (2880 * (enginePulley/motorPulley))/360; //2880 = max rpm of motor
int rowCount = 1;
int timeResolution; //the time interval in ms of the chosen data file
boolean fileSelected = false;
boolean run = false;
boolean pause = false;
boolean stop = false;
int time, rpm;
boolean debounce = true; //ensures button is released before it can be pressed again
int stopCount = 0; //how long before program closes
int timeRunning = 0; //time the program has spent running
int timePaused = 0;
String fileName;

void setup() 
{
  size(360, 360, P2D);
  background(50);

  selectInput("Select a file to process:", "fileSelected");
  //table = loadTable(file, "header");

  frameRate(1000); //sets framerate

  //println(Serial.list()); // List COM-ports
  port = new Serial(this, Serial.list()[5], 9600);


}

void fileSelected(File selection) //selects the file
{
  if (selection == null) 
  {
    println("Window was closed or the user hit cancel.");
  } 
  else 
  {
    println("User selected " + selection.getAbsolutePath());
    fileName = selection.getName();
    table = loadTable(selection.getAbsolutePath(), "header");
    fileSelected = true;
    TableRow row1 = table.getRow(1);
    TableRow row2 = table.getRow(2);
    int time1 = row1.getInt("time");
    int time2 = row2.getInt("time");
    timeResolution = time2 - time1;
  }
}

void draw() 
{
  while (fileSelected == false) //Does not run unti a file has actually been selected
  {
    delay(1);
  }

  clear();
  //println(frameRate); //use for testing a specific variable

  if (stop == false) //normal running section of program
  {
      if (run == true) //loads row data
      {
        timeRunning = millis() - timePaused;
        nextRow();
      }

      else
      {
        timePaused = millis() - timeRunning;
      }

      //println(rpm);
      update(0, rpm/calibrationFactor); //update serial signal being sent to arduino

      strokeWeight(10);
      stroke(0, 191, 255);
      fill(0, 0, 0);
      //ellipse(180, 180, rpm/24,rpm/24);
      arc(180,180,180,180, 0, radians(rpm/24)); //draws an arc whic represents the rpm value
      fill(255);
      text(rpm, 163, 185);
      text("rpm",166,195);
      text((float) time/1000, 30, 230);
      text("time (s)", 30, 240); //displays the time and rpm values
      text(fileName,30,30);
      text("timeR: " + (float) timeRunning/1000, 30, 260);

      if (run == false) //displays start button
      {
       strokeWeight(0);
        fill(51,255,51);
       rect(160,320,50,20);
       fill(0);
       text("START",165,332);


      }

      if (run == true) //displays pause button
      {
        strokeWeight(0);
        fill(255,153,51);
       rect(160,320,50,20);
       fill(0);
       text("PAUSE",165,332);

      }

      strokeWeight(0);
        fill(255,0,0);
       rect(230,320,50,20);
       fill(0);
       text("STOP",235,332);  

      if (mousePressed &amp;&amp; overRect(160,320,50,20) &amp;&amp; debounce) //detects if start/pause button has been pressed
       {
         debounce = false;
         if (run == false)
           run = true;
         else if (run == true)
           run = false;
        }

      if (mousePressed &amp;&amp; overRect(230,320,50,20) &amp;&amp; debounce)
      {
        stop = true;
      }

      if (rowCount &gt;= table.getRowCount()) //end program when end of file is reached
      {
        stop = true;
      }
  }

  else if (stop == true)
  {

    fill(255);
    text("Run finished",150,160);
    stopCount++;
    if (stopCount &gt;= 500)
      exit();
  }
}

boolean overRect(int x, int y, int width, int height) //checks to see if the mouse is over the defined rectangle
{
  if (mouseX &gt;= x &amp;&amp; mouseX &lt;= x+width &amp;&amp; 
      mouseY &gt;= y &amp;&amp; mouseY &lt;= y+height) {
    return true;
  } 
  else 
  {
    return false;
  }
}

void nextRow() //loads data from the next row in the table
{
  TableRow row = table.getRow(rowCount);
  time = row.getInt("time");
  if (time &lt;= timeRunning) //loads new rpm if we have reached that time
  {
    rpm = row.getInt("rpm"); 
    rowCount++;
  }
  if(time + timeResolution &lt; timeRunning) //catches up if it falls behind
  {
     rowCount++; 
     println(rowCount);
  }

}

void mouseReleased() //ensures mouse is released before it can be pressed again
{
   debounce = true; 
}

void update(int x) //updates output to arduino
{
  //Calculate servo postion from mouseX
  xpos= x/2;
  ypos = y/2;
  //Output the servo position ( from 0 to 180)
  port.write(xpos+"x");
  port.write(ypos+"y");
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>CSV table get row in Class</title>
      <link>https://forum.processing.org/two/discussion/23201/csv-table-get-row-in-class</link>
      <pubDate>Sun, 25 Jun 2017 12:36:56 +0000</pubDate>
      <dc:creator>pigeon</dc:creator>
      <guid isPermaLink="false">23201@/two/discussions</guid>
      <description><![CDATA[<p>I am merging previous code with the 'Load save table' example in Processing. When merging and adapting to using a Class I am not getting the expected behaviour I had previously.</p>

<p>I am attempting to recreate the stepping through each rowcount as in the working code below.</p>

<pre><code> if (i&lt; table.getRowCount()) {
    row = table.getRow(i);
    k=row.getInt("y");
    x=row.getInt("x");
  }

  //draw white ellipse visual
  ellipse(x*diam, y, diam, diam);

  // step next circle up
  y+=Step;

  // -- if off the set upper limit of the line,
  // swing right 


  if (frameCount%(k/Step)==0) {
    x+=Step;

    y=starty;
    // increment row counter
    i=i+1;
  }
</code></pre>

<p>However, when using a Class I am making a mistake somewhere parsing the i variable from the Class method move().This is stopping the i variable incrementing.</p>

<p>I am expecting k to print out the data in column named "y" in the csv file. I am expecting i to print out a number incrementing by 1 each time variable y reaches the value of k.</p>

<p>From printing out my variables i,k,x</p>

<p>k is successfully getting the data from csv file column named "y"</p>

<p>x is successfully getting the data from csv file column named "x"</p>

<p>y is successfully incrementing</p>

<p>i is not incrementing</p>

<p>y is not registering it has reached k.</p>

<p>Below is the code using a Class.</p>

<pre><code>    // An Array of Dot objects

    Dot[] dots;
    // A Table object
    Table table;
    float diam=10.0;
    int i;

    void setup() {  
      size(560, 420);
      loadData();
      background(0);
      // set the animation speed
      frameRate(10);
    }

    void draw() {
      // Display all dots
      for (Dot d : dots) {
        d.display();
        d.move();
      }

    }

    void loadData() {
      // Load CSV file into a Table object
      // "header" option indicates the file has a header row
      table = loadTable("data.csv", "header");

      // The size of the array of Dot objects is determined by the total number of rows in the CSV
      dots = new Dot[table.getRowCount()]; 

      // You can access iterate over all the rows in a table
      int rowCount = 0;
      for (TableRow row : table.rows()) {
        // You can access the fields via their column name (or index)
        if (i&lt; table.getRowCount()) {
          row = table.getRow(i);
          float x = row.getFloat("x");
          float k = row.getFloat("y");
          float d = row.getFloat("diameter");


          //String n = row.getString("name");
          // Make a fot object out of the data read
          dots[rowCount] = new Dot(i,k, x, d);

          rowCount++;
        }
      }

      //  check to see if at end of data
      if (i == table.getRowCount()) {
        i = 0;//if so, loop back to first row
      }
    }

    //
   //DOT CLASS
   //
    class Dot {
      float x =10.0;
      float y=10.0;
      float diam=10.0;
      float k;
      int step=10;
      int startx =10;
      int starty=10;

      float i=0;

      Dot(float i_,float k_, float x_,float diam_) {
        k=k_;
        x=x_;
        i=i_;
        diam=diam_;
      }




      void display() {
        noStroke();
        fill(255);
        // draw a circle
        ellipse(x*diam, y, diam, diam);
      }

      void move() {
        // move next circle to the right
        y+=step;

        // -- if off the right edge of the line,
        // swing down and all the way to the left
        if (frameCount%(k/step)==0) {
          x+=step;
          y=starty;
          // increment row counter
          i=i+1;
        }

        // if off the bottom of the page, stop
        if (x&gt;=width) {
          fill(0);
          text("done", width/2, height/2);
          noLoop();
        }
      }
    }
</code></pre>

<p>I have also tried to include an animate() function as my thoughts were the loadData() function only occurs once as it is called in the void setup() so cannot be used to call variables in the move() method. However, it results in one static dot rather than dots incrementing down and right as the i variable increments.</p>

<pre><code>void animate() {
  // initial location and size
  startx =10;
  starty =10;

  Step = 10;

  // Create a new row
  TableRow row = table.getRow(0);
  // Set the values of that row
  float x = row.getFloat("x");
  float k = row.getFloat("y");


  //if (frameCount%((mh+10)/Step)==0) {
  if (frameCount%(k/Step)==0) {
    x+=Step;

   int  y=starty;
    // increment row counter
    i=i+1;
  }
  //  check to see if at end of data
  if (i == table.getRowCount()) {

    i = 0;//if so, loop back to first row
  }


  // And reloading it
  loadData();
}
</code></pre>

<p>This also seems like a repeat of what should be happening in move() method. 
Any help or pointers in the direction I'm missing are greatly appreciated. 
Thanks</p>
]]></description>
   </item>
   <item>
      <title>Program freezes on loadTable()</title>
      <link>https://forum.processing.org/two/discussion/23089/program-freezes-on-loadtable</link>
      <pubDate>Fri, 16 Jun 2017 14:34:59 +0000</pubDate>
      <dc:creator>adomarc</dc:creator>
      <guid isPermaLink="false">23089@/two/discussions</guid>
      <description><![CDATA[<p>The following program appears to freeze on the loadTable() line. I can get the program to work fine in debugger mode by stepping through the code but it does not seem to want to execute properly with the normal run mode.</p>

<pre><code>Table dotdata;
String filepath="";
String savefilepath="";
int columncount= 0;
int rowcount=0;

void setup() {
  size(500, 500);
  background(0);
  dotdata=new Table();
}

void draw() {
  selectInput("Select .txt file", "fileSelected");

  while (filepath=="") {
  };

  dotdata = loadTable(filepath, "tsv");
  print("hello");

  for (int i=0; i&lt;7; i++) {
    dotdata.removeRow(0);
  }
  dotdata.removeColumn(5);
  dotdata.removeColumn(4);
  dotdata.removeColumn(1);
  dotdata.removeColumn(0);

  dotdata.addColumn();
  dotdata.addColumn();
  dotdata.addColumn();

  //int columncount= dotdata.getColumnCount();
  int rowcount=dotdata.getRowCount();


  for (int i=0; i&lt;rowcount; i++) {
    dotdata.setFloat(i, 2, dotdata.getFloat(i, 0)+150);
    dotdata.setFloat(i, 3, dotdata.getFloat(i, 1)-150);
  }

  for (int i=0; i&lt;rowcount; i++) {
    dotdata.setString(i, 4, str(dotdata.getFloat(i, 2)) + "," + str(dotdata.getFloat(i, 3)));
  }

  filepathnaming();

  saveTable(dotdata, savefilepath);
  exit();
}



void fileSelected(File selection) {
  if (selection == null) {
    println("Window was closed or the user hit cancel.");
    exit();
  } else {
    filepath=selection.getAbsolutePath();
  }
}

void filepathnaming() {
  savefilepath="";
  String[] filepathlist = split(filepath, "\\");

  for (int i=0; i&lt;filepathlist.length-1; i++) {
    savefilepath +=filepathlist[i]+ "\\";
  }

  savefilepath += filepathlist[filepathlist.length-1].substring(0, filepathlist[filepathlist.length-1].indexOf(".txt"))+"_update.csv";

  println(savefilepath);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>selectInput and graph</title>
      <link>https://forum.processing.org/two/discussion/22987/selectinput-and-graph</link>
      <pubDate>Thu, 08 Jun 2017 11:44:09 +0000</pubDate>
      <dc:creator>dwill0806</dc:creator>
      <guid isPermaLink="false">22987@/two/discussions</guid>
      <description><![CDATA[<p>Hello all, I want to write a code to select a ".csv" file and graph the corresponding data. So far I've been able to do those separately but not together.</p>

<pre><code>Table table;
String myFilePath;
TableRow row;
float Time;
float Manom;
float Temp;
float P1;
float GV1;
float P2;
float GV2;
float P3;
float GV3;
float P4;
float GV4;
float P5;
float GV5;
float P6;
float GV6;
float x;
int var;
Bubble[] bubbles;


void setup() {
  size(1000, 800);
  surface.setResizable(true);
  selectInput("Select a file to process:", "fileSelected");
  loadData();
}

void fileSelected(File selection) {
  myFilePath = selection.getAbsolutePath();
  table = loadTable(myFilePath, "header");
}

void draw(){
  if(table == null){
    background(0,0,155);
    noLoop();
  } else {
    background(155,50,50);
    for (int i = 0; i &lt; bubbles.length; i++) {
    bubbles[i].display();
    }
  }
}

void loadData(){
  if (table != null){
    background(70);
    table = loadTable(myFilePath, "header");
    bubbles = new Bubble[table.getRowCount()]; 
    for (int i = 0; i &lt; table.getRowCount(); i++){
      row = table.getRow(i);
      Time = row.getInt("Time (s)");
      Manom = row.getFloat("1");
      Temp = row.getFloat("2");
      P1 = row.getFloat("3");
      P2 = row.getFloat("4");
      P3 = row.getFloat("5");
      P4 = row.getFloat("6");
      P5 = row.getFloat("7");
      P6 = row.getFloat("8");
      GV1 = row.getFloat("9");
      GV2 = row.getFloat("10");
      GV3 = row.getFloat("11");
      GV4 = row.getFloat("12");
      GV5 = row.getFloat("13");
      GV6 = row.getFloat("14");
      x = map(Time, 0, table.getRowCount(), 100, 900);
    }
  }
}
</code></pre>

<p>Main code with class Bubble</p>

<pre><code>class Bubble {
  float x,y;
  float diameter;


  Bubble(float x_, float y_, float diameter_) {
    x = x_;
    y = y_;
    diameter = diameter_;
  }


  void display() {
    stroke(0);
    strokeWeight(2);
    noFill();
    ellipse(x,y,diameter,diameter);
  }
}
</code></pre>

<p>running this code gives me this error</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/696/GD5GX0BCUTQC.png" alt="Untitled" title="Untitled" /></p>
]]></description>
   </item>
   <item>
      <title>How to create a grid of colours using data from a csv file.</title>
      <link>https://forum.processing.org/two/discussion/22832/how-to-create-a-grid-of-colours-using-data-from-a-csv-file</link>
      <pubDate>Wed, 31 May 2017 05:53:51 +0000</pubDate>
      <dc:creator>lanelps</dc:creator>
      <guid isPermaLink="false">22832@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to create a grid of 3x100, and in each individual square is a different colour, which is getting its information from a csv file which contains rgb values for each square. The issue I'm having is the not all the colours are displaying, all the squares are the same colour except the first square which is at x:0 and y:0.</p>

<p><img src="" alt="" />
<img src="https://forum.processing.org/two/uploads/imageupload/288/J0J3LK8M0NW6.png" alt="Screen Shot 2017-05-31 at 5.50.15 PM" title="Screen Shot 2017-05-31 at 5.50.15 PM" /></p>

<pre><code>int totalrows;
float [] therows;

float [] theR;
float [] theG;
float [] theB;

squares [] s;

void setup() {
  size(600, 600, P2D);
  frameRate(2);
  //background(255);

  loadData();

  s = new squares[totalrows];
}

void draw() {

  background(255);
  for (int i=0; i&lt;totalrows; i++) {
    s[i] = new squares(theR[i], theG[i], theB[i]);
    s[i].run();
  }
}

class squares {

  float r;
  float g;
  float b;

  float x;
  float y;

  squares(float _r, float _g, float _b) {

    r = _r;
    g = _g;
    b = _b;
  }

  void run() {

    stroke(0);
    //noStroke();

    for (int i=0; i&lt;3*5; i+=5) {
      for (int j=0; j&lt;totalrows*5; j+=5) {

        rect(i, j, 5, 5);
        fill(r, g, b);
      }
    }
  }
}

void loadData() {

  Table table;
  TableRow row;

  table = loadTable("1-5-2017.csv", "header");
  totalrows = table.getRowCount();

  theR = new float[totalrows];
  theG = new float[totalrows];
  theB = new float[totalrows];

  for (int i=0; i&lt;totalrows; i++) {
    row = table.getRow(i);
    theR[i] = row.getInt("R");
    theG[i] = row.getInt("G");
    theB[i] = row.getInt("B");
  }
}
</code></pre>

<p>Here is a link to the files.</p>

<p><a rel="nofollow" href="https://drive.google.com/open?id=0B8ubSSzmgWImNldSOGtfQkNHN1k">https://drive.google.com/open?id=0B8ubSSzmgWImNldSOGtfQkNHN1k</a></p>
]]></description>
   </item>
   <item>
      <title>Expected Null Pointer  - Please help</title>
      <link>https://forum.processing.org/two/discussion/22036/expected-null-pointer-please-help</link>
      <pubDate>Sun, 16 Apr 2017 16:24:10 +0000</pubDate>
      <dc:creator>leeoko1</dc:creator>
      <guid isPermaLink="false">22036@/two/discussions</guid>
      <description><![CDATA[<p>Hi , I am trying to plot the data with the country that the user has entered.</p>

<p>My data is formatted in the following way.</p>

<pre><code>Country ,1975 ,1976 ....2014 ; 
Afghanistan, 23, 24 ....40. 
</code></pre>

<p>I want to plot the row data with the code below but I am getting Null Pointer Exception. I can't see where I have gone wrong. Can someone please help me ?</p>

<pre><code>import org.gicentre.utils.stat.*;
import org.gicentre.utils.gui.*;
XYChart Chart;
Table Men ;
TextInput textInput;
float[] yearstoplot = new float[40];

    void setup()
    {
      size(1000, 1000);
      Table Men = loadTable ("Mendatare.csv","header,csv");
      Chart =new XYChart(this);
      Chart.setMaxX(2015);
      Chart.setMinX(1974);
      Chart.setXFormat("####");
      Chart.setMaxY(30);
      Chart.setMinY(18);
      Chart.showXAxis(true);
      Chart.showYAxis(true);
      Chart.setPointColour(color(180,4, 110));
      Chart.setPointSize(5);
      Chart.setLineColour(color(180,4, 110));
      Chart.setLineWidth(2);
      textSize(20);
      PFont fonttextbox = createFont("BodoniMT-48",14);
      textInput= new TextInput(this,fonttextbox,14);

     for (int i=0; i&lt;yearstoplot.length; i++)
      {
        yearstoplot[i] = (i+1975);
      }
      println(yearstoplot); 

    }


    void keyPressed () 
    {
     textInput.keyPressed();

     if  (keyCode ==ENTER))
      {
            String countrytoplot = textInput.getText();
            TableRow target = Men.findRow(countrytoplot, "Country/Region/World"); // here is the problem
             float x0 = target.getFloat(3);  //get value from column 3
             float x1 = target.getFloat(4);
             float x2 = target.getFloat(5);
             float x3 = target.getFloat(6);
             float x4 = target.getFloat(7);
             float x5 = target.getFloat(8);
             float x6 = target.getFloat(9);
             float x7 = target.getFloat(10);
             float x8 = target.getFloat(11);
             float x9 = target.getFloat(12); //get value from column 12

             float[] datatoplot = {x0,x1,x2,x3,x4,x5,x6,x7,x8,x9}; //aggregate the values 

             Chart.setData(yearstoplot,datatoplot);
      }     
     }

    void draw()
    {

      background(255);


      fill(0);
      textAlign(CENTER);
      text("Obesity over the years for countries",300, 20);

      strokeWeight(2.0);
      stroke(40);
      fill(0,200);
      rect(770,20,215,60,8);
      textAlign(RIGHT);
      fill(0);
      textSize(10);
      text("Please type in a country name", width-50,30);
      textInput.draw(780,40);
      Chart.draw(30,80,width-400,height-300);
    }
</code></pre>

<p>Is there a better way of doing it ?</p>
]]></description>
   </item>
   <item>
      <title>Pie chart that will show the different billionaires in Eastern Asia, looking for improvement</title>
      <link>https://forum.processing.org/two/discussion/21841/pie-chart-that-will-show-the-different-billionaires-in-eastern-asia-looking-for-improvement</link>
      <pubDate>Wed, 05 Apr 2017 20:50:41 +0000</pubDate>
      <dc:creator>wrh013</dc:creator>
      <guid isPermaLink="false">21841@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to improve this code and make it a more efficient or more effective program. I want to display the pie chart and develop a way to show the different countries based on how many billionaires they have and hopefully the number along with it. If anyone could lend me some insight or help out all is appreciated. Thanks!</p>

<p>Here is the dataset that I used... it is in the format of .csv and I included it in the folder of my data which is in p5.js 
<a href="https://drive.google.com/open?id=0B4D3N0Bg20n5SWV5bXFsQlFiWVk" target="_blank" rel="nofollow">https://drive.google.com/open?id=0B4D3N0Bg20n5SWV5bXFsQlFiWVk</a></p>

<pre><code>//global variable of the billionaires csv
var countryTable;

var citizenshipData=[];

//array that the values are being pushed into
var countries = [];


function preload(){
  countryTable= loadTable("billionaires.csv","csv","header");
}

function setup() {
  createCanvas(1000,1000);
  background(125,125,125);

  //gets the data of the citizenship of different countries
  citizenshipData=countryTable.getColumn("citizenship");
  //println(citizenshipData);

  //only getting the billionaires that have a citizenship in the region of eastAsia
  var eastAsia = citizenshipData.slice(1,536);

  //Layout for what the lines of code mean

  var chineseBillionaires= eastAsia.slice(0,153);//number of billionaires in country sliced from the dataset
  var china=(chineseBillionaires.length);  //takes the number by looking at the length
  countries.push(china);  //adds it to the array of countries


  var japaneseBillionaires=eastAsia.slice(261,357);
  var japan=(japaneseBillionaires.length);
  countries.push(japan);

  var hongkongBillionaires=eastAsia.slice(153,230);
  var hongkong=(hongkongBillionaires.length);
  countries.push(hongkong);

  var taiwaneseBillionaires=eastAsia.slice(471,511);
  var taiwan=(taiwaneseBillionaires.length);
  countries.push(taiwan);

  var southKoreanBillionaires= eastAsia.slice(435,471);
  var southKorea=(southKoreanBillionaires.length);
  countries.push(southKorea);

  var indonesianBillionaires=eastAsia.slice(230,261);
  var indonesia=(indonesianBillionaires.length);
  countries.push(indonesia);

  var malaysianBillionaires= eastAsia.slice(359,387);
  var malaysia=(malaysianBillionaires.length);
  countries.push(malaysia);

  var singaporeanBillionaires= eastAsia.slice(409,435);
  var singapore= (singaporeanBillionaires.length);
  countries.push(singapore);

  var thaiBillionaires=eastAsia.slice(511,534);
  var thailand= (thaiBillionaires.length);
  countries.push(thailand);

  var filipinoBillionaires= eastAsia.slice(387,409);
  var phillipines=(filipinoBillionaires.length);
  countries.push(phillipines);

  var macaneseBillionaires= eastAsia.slice(357,359);
  var macau=(macaneseBillionaires.length);
  countries.push(macau);

  var vietnameseBillionaires=eastAsia.slice(534,535);
  var vietnam=(vietnameseBillionaires.length);
  countries.push(vietnam);
  println(countries);

}


function draw() {
  pieChart(650,countries);
  noLoop();
  textSize(32);
  fill(0);
  text("Multi-decade database of the Billionaires",width/5,height/7);
  text("in East Asia by the numbers",width/5,height/5.5);
}


function pieChart(diameter,data){
  var lastCountry=0;
  strokeWeight(6);
  for(var i=0; i &lt; data.length; i++){
    fill(random(0,255),random(0,255),random(0,255));
    arc(width/2, height/1.7, diameter, diameter, lastCountry, lastCountry+radians(countries[i]));
    lastCountry += radians(countries[i]);
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>images representing parts of dataset</title>
      <link>https://forum.processing.org/two/discussion/21325/images-representing-parts-of-dataset</link>
      <pubDate>Sat, 11 Mar 2017 00:23:24 +0000</pubDate>
      <dc:creator>nicelyfriedwing</dc:creator>
      <guid isPermaLink="false">21325@/two/discussions</guid>
      <description><![CDATA[<p>I'm new to processing and I'm working with a dataset (.csv). The data set looks like this: <a href="http://imgur.com/a/e0ZcO" target="_blank" rel="nofollow">http://imgur.com/a/e0ZcO</a></p>

<p>I am trying to represent the total time spent on the phone (duration) per day, with an image - the PShape's in the code below. I'm having trouble figuring out how to have the image be representative of a day's worth of minutes rather than each call, which is what it is doing now.</p>

<pre><code>Table data; //defining the Table class
int rowCount;

PShape snowOne, snowTwo, snowThree, snowFour, snowFive;

String callMonth;
int callDay, callDuration;

void setup() {
  size(760, 700);
  snowOne = loadShape("snow1.svg");
  snowTwo = loadShape("snow2.svg");
  snowThree = loadShape("snow3.svg");
  snowFour = loadShape("snow4.svg");
  snowFive = loadShape("snow5.svg");
  data = loadTable("dataSet.csv", "header"); //loading the dataset with its headers
  rowCount = data.getRowCount();
}

void draw() {
  background(255);
  for (int row = 0; row &lt; rowCount; row = row + 1) { //getting the data rows
    callMonth = data.getString(row,"month");
    callDay = data.getInt(row,"day");
    callDuration = data.getInt(row,"duration");

    if(callDuration &gt; 0 &amp;&amp; callDuration &lt; 10){ //1-10 min
      shape(snowOne, row*110, 35, 100, 100);
    } 
      else if(callDuration &lt; 0) {
        ellipse(row*110, 35, 100, 100); //no calls made
      }
      else if(callDuration &gt; 11 &amp;&amp; callDuration &lt; 20){ //11-20 min

        shape(snowTwo, row*110, 35, 100, 100);
      }
      else if(callDuration &gt; 21 &amp;&amp; callDuration &lt; 30){ //21-30 min
        shape(snowThree, row*110, 35, 100, 100);
      }
      else if(callDuration &gt; 31 &amp;&amp; callDuration &lt; 40){ //31-40 min
        shape(snowFour, row*110, 35, 100, 100);
      }
      else if(callDuration &gt; 41) {
        shape(snowFive, row*110, 35, 100, 100); //41+ min
      }

  }
}
}
</code></pre>

<p>Another thing I have trouble with is containing or "breaking" the row so that it fits on the window. Right now it is mapping the data in a linear line,rather than breaking it into 5 which is what I want(<a href="http://imgur.com/a/kPBvi" target="_blank" rel="nofollow">http://imgur.com/a/kPBvi</a>)</p>

<p>Thanks! If this confusing I apologize.</p>
]]></description>
   </item>
   <item>
      <title>How to take data from a ControlP5 scrollable list, and use it to select a row in spreadsheet?</title>
      <link>https://forum.processing.org/two/discussion/21226/how-to-take-data-from-a-controlp5-scrollable-list-and-use-it-to-select-a-row-in-spreadsheet</link>
      <pubDate>Tue, 07 Mar 2017 16:27:20 +0000</pubDate>
      <dc:creator>Attrup</dc:creator>
      <guid isPermaLink="false">21226@/two/discussions</guid>
      <description><![CDATA[<p>Hello
I'm trying to make a program which calculates values which it gets from a spreadsheet. I'm using a ControlP5 scrollable list to show all the possible selection. Each item in the list represents a row in the spreadsheet. To each row there is 7 columns.</p>

<p>So my question is how do i let processing know or rather code, that the item selected in the list is a row in the spreadsheet? It's very poorly explained i know, but i will try to explain further if need! Thank you so much in advance!</p>

<p>A simplified version of my code:</p>

<p>`</p>

<pre><code>    import controlP5.*;
    import java.util.*;

    ControlP5 cp5;

    ScrollableList initialBodyList;

    Button butDeltaVplanet;

    Table Planeter;

    Textfield required_delta_V;

    void setup() {
      size(500, 500);
      cp5 = new ControlP5(this);

       Planeter = loadTable("DatasheetPlanets.csv", "header");

      butDeltaVplanet = cp5.addButton("Calculate required Delta V")
        .setPosition(300, 50)
        .setColorForeground(#EA0037)
        .setColorActive(#FF4343)
        .setSize(130, 30);
      List body = Arrays.asList("Kerbol", "Moho", "Eve", "     Gilly", "Kerbin", "     Mun", "     Minmus", "Duna", "     Ike", "Dres", "Jool", "     Laythe", "     Vall", "     Tylo", "     Bop", "     Pol", "Eeloo");

      initialBodyList = cp5.addScrollableList("Initial body")
        .setPosition(70, 50)
        .setSize(200, 300)
        .setBarHeight(30)
        .setItemHeight(20)
        .setBackgroundColor(#EA0037)
        .setColorForeground(#EA0037)
        .setColorActive(#FF4343)
        .addItems(body)
        .setOpen(false);

      required_delta_V = cp5.addTextfield("Required Delta V m/s")
        .setPosition(300, 120)
        .setSize(130, 30);


      ControlP5.printPublicMethodsFor(Textfield.class);
    }

    void draw() {
      background(200);
    }

    public void controlEvent(ControlEvent theEvent) {

      if (theEvent.isFrom(butDeltaVplanet)) {

        int planet1 = Planeter.getRow(3).getInt("DeltaVtoKerbinorbit");

        int planet2 = Planeter.getRow(4).getInt("DeltaVtoKerbinorbit");

        float deltaV = 0;

        deltaV = planet1 + planet2;

        required_delta_V.setText("   " + deltaV);
      }
    }`
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to convert a 1D array with csv entries to a 2D array</title>
      <link>https://forum.processing.org/two/discussion/19888/how-to-convert-a-1d-array-with-csv-entries-to-a-2d-array</link>
      <pubDate>Fri, 23 Dec 2016 02:01:54 +0000</pubDate>
      <dc:creator>BlindAssassin111</dc:creator>
      <guid isPermaLink="false">19888@/two/discussions</guid>
      <description><![CDATA[<p>Okay, so I am trying to figure out how to convert a 1D array, where each entry is a string of 8 comma delimited values, into a 2D array. There number of rows depends on what file the use is reading, so that is not a constant.</p>

<p>A small snippet of the 1D array:</p>

<pre><code>205/55R16,24,5.5-7.5,6.5,8.4,7.6,24.9,837

205/45R17,23,6.5-7.5,7,8.1,7.4,24.3,859

205/50R17,25,5.5-7.5,6.5,8.4,7.5,25.1,830

215/45R17,24,7-8,7,8.4,7.7,24.7,845
</code></pre>

<p>The first entry in every row is a string, and the following 7 are values I want to use later as numbers. So how would I go about storing the first entry into a single column 1D array, and the last 7 entries into another 2D array?</p>

<p>To make it more complicated the third entry needs to be split into two different entries, making the 2D array an [m][8] array, m being the number of rows from the read file. The reason I won't be doing this by hand is I will in the end have a couple thousand lines to split, which is not an efficient process.</p>

<p>Thank you for the help!</p>
]]></description>
   </item>
   <item>
      <title>Map delimiters: can't make vertex() to draw them</title>
      <link>https://forum.processing.org/two/discussion/19398/map-delimiters-can-t-make-vertex-to-draw-them</link>
      <pubDate>Tue, 29 Nov 2016 17:01:30 +0000</pubDate>
      <dc:creator>mmammana</dc:creator>
      <guid isPermaLink="false">19398@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,
I am trying to make a map of Buenos Aires neighbourhoods. 
I've created a csv file with some coordinates to delimit some of the neighbourhoods. I want the program to draw and fill the limits, using beginShape/vertex/endShape.
The coordinates are loaded into a table, and then, two loops read each row/column and get the values for each neighbourhood (one row per neighbourhood, with 4 pairs of values, for a 4 sided polygon each).
When all the vertex points are drawn for that polygon, the inner loop ends, and the program runs the endShape(CLOSE) to close the limits, and starts the next row (that's why I put the endShape(CLOSE) outside the inner loop).</p>

<p>I can't figure out why it is not working. I've put a println() to check if the values retrieved in each iteration are ok. The values are ok, but vertex does not draw the polygon. I've also tried leaving the image (svg) out, because perhaps, the loop draws it behind the map, but again, no success. 
Maybe the endShape should not be outside the second loop, meaning that all code between beginShape and endShape must remain together?
Any idea? Thanks so much in advance,
Marcelo</p>

<p>This is the program (Processing 2):</p>

<pre><code>PShape mapaBA;
Table table;

void setup(){
  size(800,800);
  noLoop();
  table = loadTable("barrios.csv"); // coords for some neighborhoods limits
  mapaBA = loadShape("CABA.svg"); // map of Buenos Aires city
}

void draw(){
    shape(mapaBA,0,0,width,height);
    for (int i=0;i&lt;table.getRowCount();i++){ 
      for (int e =0;e&lt;table.getColumnCount()-1;e=e+2){ 
          beginShape();
          int x = table.getInt(i,e);
          int y = table.getInt(i,e+1);
          println(i, e, x,y); // just to test if values are ok
          vertex(x,y); // should draw a polygon that delimites a neighbourhood, based on coords
        }
          endShape(CLOSE);
    }

}
</code></pre>

<p>The csv file contains the following values:</p>

<pre><code>642,320,554,326,564,365,643,355
647,355,563,364,561,401,648,393
559,403,612,400,617,438,567,468
649,394,612,398,618,440,659,431
</code></pre>
]]></description>
   </item>
   </channel>
</rss>