<?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 getrowcount() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=getrowcount%28%29</link>
      <pubDate>Sun, 08 Aug 2021 21:28:33 +0000</pubDate>
         <description>Tagged with getrowcount() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedgetrowcount%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <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>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>NaN Problem</title>
      <link>https://forum.processing.org/two/discussion/22463/nan-problem</link>
      <pubDate>Mon, 08 May 2017 16:03:05 +0000</pubDate>
      <dc:creator>Bobba93</dc:creator>
      <guid isPermaLink="false">22463@/two/discussions</guid>
      <description><![CDATA[<p>Hey, I'm trying to make a data visualization with a dataset about central power stations, that I put here, but when I try to visualize there are few power station "ball". When I try to understand the problem with Println(longitude), it tells me "map(NaN, -180, 180, 0, 1000) called, which returns NaN (not a number)". I think that the code is right, and I don't understand the problem with the .csv. Thank You!</p>

<p><a href="https://docs.google.com/spreadsheets/d/1B6ezcmjntEI-nI6_miO6UQaOU78ZXnDep-qtyVUWmJ4/edit?usp=sharing" target="_blank" rel="nofollow">https://docs.google.com/spreadsheets/d/1B6ezcmjntEI-nI6_miO6UQaOU78ZXnDep-qtyVUWmJ4/edit?usp=sharing</a></p>

<pre><code>PImage mappa; 
Table dati;

void setup(){
  size(1000, 500); 
  mappa= loadImage("world.png"); 
  dati= loadTable("energydata.csv", "header"); 
}

void draw(){
image(mappa, 0, 0, width, height);


 for( int riga=0; riga &lt; dati.getRowCount(); riga++){
float lat= dati.getFloat(riga,0); 
float lon= dati.getFloat(riga,1); 
/*String nome = dati.getString(riga,2);
String stato = dati.getString(riga,3);
float potenza= dati.getFloat(riga,4);
String tipo= dati.getString(riga,5);


float la=map(lat, 90, -90, 0, height);
float lo=map(lon, -180,180,0,width);
println(lon);

fill(#4AF2A1,80);
noStroke();
ellipse(lo,la,10,10);

noLoop();  }}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to nicely extract data from a .csv table and display it ?</title>
      <link>https://forum.processing.org/two/discussion/21854/how-to-nicely-extract-data-from-a-csv-table-and-display-it</link>
      <pubDate>Thu, 06 Apr 2017 10:04:58 +0000</pubDate>
      <dc:creator>Spiritofthecode</dc:creator>
      <guid isPermaLink="false">21854@/two/discussions</guid>
      <description><![CDATA[<p>Hello there !</p>

<p>I've got 2 csv files on my hand ; the first  listing restaurants, with 3 columns(coordinate x, coordinate y, restaurant name) and another listing deliveries (coordinate x, delivery coordinate y , name of the restaurante the delivery was done by).</p>

<p>I need to :
1) Display the number of deliveries made for each restaurant. 
2) The average distance of the deliveries for each restaurant (distance being calculated by this formula = sqrt(sq(x1-x2)+sq(y1-y2) at least I figured something out :p)</p>

<p>For the first, I made a class which looks like this :</p>

<p>Then I'm trying to go trought the deliveries table and change the arraylist of objects so that when the string happens to be the same in a row and the arraylist object the object counts gets to +1. But it doesn't seem to work. Any tips appreciated for the step 2, also.</p>
]]></description>
   </item>
   <item>
      <title>Make a grid from a linear index</title>
      <link>https://forum.processing.org/two/discussion/19258/make-a-grid-from-a-linear-index</link>
      <pubDate>Thu, 24 Nov 2016 01:41:46 +0000</pubDate>
      <dc:creator>nicotron</dc:creator>
      <guid isPermaLink="false">19258@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone, this is my first time writing in the forum, all the other times I had a question, someone already did it and some other one answered!</p>

<p>This time I have the problem that with a csv file which goes to 120 rows, I pass all that data in the constructor, but I haven`t find a way to put the 120 objects in a 60 x 20 grid.</p>

<pre><code>Objet[] o;  
void setup() {  
 size(1000, 800);  
 table = loadTable("data.csv", "header");  
 o = new Objeto[table.getRowCount()];  
 for (int i = 0; i &lt; table.getRowCount(); i++) {  
 int inde = i;  
  TableRow r = table.getRow(i);  
  String date = r.getString("date");  
  int num = r.getInt("num");  
  int time = r.getInt("time");  
  int score = r.getInt("score");  

  o[i] = new Objet(index, date, num, time, score);  
} 
</code></pre>
]]></description>
   </item>
   <item>
      <title>Split() function not working</title>
      <link>https://forum.processing.org/two/discussion/17104/split-function-not-working</link>
      <pubDate>Sat, 11 Jun 2016 14:59:47 +0000</pubDate>
      <dc:creator>ldlpdx</dc:creator>
      <guid isPermaLink="false">17104@/two/discussions</guid>
      <description><![CDATA[<p>I have a .csv file that I'm calling in JavaScript through a p5.js sketch. One of the fields contains sentences that range from 103 char to 328 char. My script calls the data and displays in randomly on the canvas. Because some of the sentences are very long, they aren't fitting on the canvas properly, so I'd like to split them into 2- or 3-line strings.</p>

<p>I won't post my whole code, but here is the setup() snippet:</p>

<pre><code>function setup() {
  canvas = createCanvas(680, 420);
  canvas.mousePressed(inWidth);
  background(51);
  // Calling noStroke once here to avoid unecessary repeated function calls
  noStroke();
  // iterate over the table rows
  for (var i = 0; i &lt; clContext.getRowCount(); i++) {
    var category = clContext.get(i, "category");
    var statement = clContext.get(i, "statement");
    var polarity = clContext.get(i, "polarity");

 // split long statements that have '\r\n' in them and add the rest as a second or third line
    statement = split(statement, "[\\r\\n]+");

 // creates `display()` object from `Statement` constructor (not shown)
    statements[i] = new Statement(category, polarity, statement);
  }
}
</code></pre>

<p>I have tried various configurations based on native js, e.g., <code>var array = sentence.split("\n").map(x =&gt; x.trim());</code>, but that just throws an error that sentence.split is not a function. And now I've tried what's there now, including putting it in a for loop, from the <a rel="nofollow" href="https://processing.org/reference/split_.html">Processing reference</a>, but I have not found a solution that works. I can still run the sketch, but the line breaks don't work.</p>
]]></description>
   </item>
   <item>
      <title>Converting Java code to Python for Dataviz</title>
      <link>https://forum.processing.org/two/discussion/14071/converting-java-code-to-python-for-dataviz</link>
      <pubDate>Fri, 18 Dec 2015 22:14:14 +0000</pubDate>
      <dc:creator>Ludopy</dc:creator>
      <guid isPermaLink="false">14071@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm currently reading the book "Getting Started with Processing" without using Java but Python instead and I'm trying to figure how to convert this piece of code into Python.</p>

<pre><code>    Table stats;

    void setup() {
      stats = loadTable("ortiz.csv");
      for (int i = 0; i &lt; stats.getRowCount(); i++) {
        // Gets an integer from row i, column 0 in the file
        int year = stats.getInt(i, 0);
        // Gets the integer from row i, column 1
        int homeRuns = stats.getInt(i, 1);   
        int rbi = stats.getInt(i, 2); 
        // Read a number that includes decimal points
        float average = stats.getFloat(i, 3); 
        println(year, homeRuns, rbi, average);
      }
    }
</code></pre>

<p>I've tried a way with importing the csv module and playing with that but I'm not sure that it's the same way as the book deal with.</p>

<p>Any help would be very appreciated! (Sorry for my skilless english)
Thanks!</p>
]]></description>
   </item>
   <item>
      <title>CSV file - how to control length of keypress?</title>
      <link>https://forum.processing.org/two/discussion/15380/csv-file-how-to-control-length-of-keypress</link>
      <pubDate>Wed, 09 Mar 2016 14:58:22 +0000</pubDate>
      <dc:creator>rachelg</dc:creator>
      <guid isPermaLink="false">15380@/two/discussions</guid>
      <description><![CDATA[<p>i have a csv file with 72 records in it. i want to display just 8 at a time, and when the arrow keys are pressed, RIGHT and LEFT, i want it to show the next 8. The following code works to a degree, but the results seem a bit random, it doesn't show the same result set every time. I should have 8 panes of 9 records. It shows 8 at a time okay, but depending on the LENGTH of the keypress, it skips ahead at different rates. I want it to show 8 different records on right arrow keypress, but it comes up with half the old screen and half new records mostly. How can I control this? Anyone shed some light? (resources down the bottom)</p>

<pre><code>import processing.video.*;
//import ddf.minim.*;
//import ddf.minim.effects.*;

Movie mymovie;
Table myresource;
String Message;
PFont myfont;
int j;
int lines=0;
int count = 9; 
int max=0;


void setup() {
  size(660, 600);
  frameRate(30);
  background(0, 0, 102);
  myfont = loadFont("DejaVu.vlw");

  myresource = loadTable("neilyoung.csv", "header");  //load csv file
  //println(myresource.getRowCount() + " total rows in table"); 
  max= myresource.getRowCount();
  fillshape();  // draw and colour the rectangle

  loadMovie();    //load vid
}


void draw() {
  if (mymovie.available() == true) {
    mymovie.read(); 
  }

  image(mymovie, 200, 20, width/3, height/4);  //display video

  fill(102, 0, 51);

  showRows(lines);  //get records
  KeyPressed(); 

}

void KeyPressed(){
   float current = mymovie.time();
   float entire = mymovie.duration();
   if (keyPressed) {
      if (key == 'f' || key == 'F') {
         mymovie.jump(current + 12); //skip forward 12 seconds
       }
       else if (key == 'b' || key == 'B') {
         mymovie.jump(current - 12);  //skip back 12 seconds
       }
       else if (key == 'e' || key == 'E') {
         mymovie.jump(entire);  //jump to the end of the video
       }
       else if (key == 's' || key == 'S') {
         mymovie.jump(0);  //jump to the start of the video
       }
       else if (keyCode == RIGHT){ 
         fillshape();
         if (lines &lt; (max-count)){
           lines++;
           //println(lines);
         }
         showRows(lines);
       }
       else if (keyCode == LEFT){
         fillshape();
         if (lines !=0){
           lines--; 
           println(lines);
         }
         showRows(lines); 
       }
    }

}

void showRows(int lines){
  textFont(myfont, 22); 
  text("Neil Young Albums", 30, 220); //heading

  int space = 27;
  int countline = 0;
    for (j = lines; j&lt;max; j++){
      TableRow row = myresource.getRow(j);
      countline++;
      int yr= row.getInt("year");
      String art = row.getString("artist");
      String tit = row.getString("title");      
      textFont(myfont, 16);

      Message = str(yr) + "  " + art + "  " + tit + "  ";  
      text(Message, 30, 250 + countline*space);

      if(countline==count){ 
        //println( j);
        break;        
       }    
     } 
}

void loadMovie(){
  // Load and play the video 
  mymovie = new Movie(this, "harvestmoon.mp4");
  mymovie.play();
}

void fillshape(){
  //refill the orange rectangle where the albums go  
    fill(204, 102, 0);
    rect(20, 180, 620, 400); 
}
</code></pre>

<p><a rel="nofollow" href="https://www.dropbox.com/s/q5shte9jxjtzaq4/DejaVu.vlw?dl=0">https://dropbox.com/s/q5shte9jxjtzaq4/DejaVu.vlw?dl=0</a>
<a rel="nofollow" href="https://www.dropbox.com/s/vahfd41188mpanc/harvestmoon.mp4?dl=0">https://dropbox.com/s/vahfd41188mpanc/harvestmoon.mp4?dl=0</a><br />
<a rel="nofollow" href="https://www.dropbox.com/s/7a7yj9b69hufzpx/neilyoung.csv?dl=0">https://www.dropbox.com/s/7a7yj9b69hufzpx/neilyoung.csv?dl=0</a></p>
]]></description>
   </item>
   <item>
      <title>How do I duplicate the class for each row in a .csv?</title>
      <link>https://forum.processing.org/two/discussion/13680/how-do-i-duplicate-the-class-for-each-row-in-a-csv</link>
      <pubDate>Fri, 27 Nov 2015 03:17:43 +0000</pubDate>
      <dc:creator>Althalus7</dc:creator>
      <guid isPermaLink="false">13680@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to create a sine wave for every row of data in the .csv but no matter what I try it doesn't seem to work.  Do I use arrays?  Can someone please tell me or show me how?</p>

<pre><code>Wave wave;
Table neutral;
//A = Amplitude
//C = Horizontal Displacement
//B = Period
void setup() {
  size(500, 500);

  neutral = loadTable("Test.csv", "header");
  println(neutral.getRowCount() + " total rows in table");


  for (TableRow row : neutral.rows ()) {
    //float A = row.getFloat("A");
    //float B = row.getFloat("B");
    //float C = row.getFloat("C");
    //println(A + " : " + B + " : " + C);
    for (int i = 0; i &lt; neutral.getRowCount (); i++) {
      float Ai = neutral.getFloat(i, 4);
      float Bi = neutral.getFloat(i, 5);
      float Ci = neutral.getFloat(i, 6);


      println(Ai + " : " + Bi + " : " + Ci);
      wave = new Wave(0, Ai, Bi/100, 100);
    }
  }
}

void draw() {
  background(255);
  translate(width/2, height/2);
  wave.update();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>lines</title>
      <link>https://forum.processing.org/two/discussion/12962/lines</link>
      <pubDate>Mon, 12 Oct 2015 14:05:27 +0000</pubDate>
      <dc:creator>btot</dc:creator>
      <guid isPermaLink="false">12962@/two/discussions</guid>
      <description><![CDATA[<p>Got another question for a second project. I want to have different lines labeled with months superposed. On that line are vertical lines marking different events. The user should be able to change between different events and for example you only see one line or if selected all off them superposed. Any tips?</p>
]]></description>
   </item>
   <item>
      <title>Getting Error on max() function</title>
      <link>https://forum.processing.org/two/discussion/11813/getting-error-on-max-function</link>
      <pubDate>Thu, 23 Jul 2015 19:41:30 +0000</pubDate>
      <dc:creator>Omme</dc:creator>
      <guid isPermaLink="false">11813@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am new to processing and new to programming in general.  Can someone please help me with the code below?</p>

<p>I believe the error is related to the line with the max() function, which I need for the map function to properly import my data.</p>

<p>The error I keep getting back is "The method max(float,float) in the type PApplet is not applicable for the arguments (float)"</p>

<p>I have no idea what I am doing wrong....Thanks in advance.</p>

<pre><code>Point [] points;
Table table;

void setup () {
  size(1000,1000);
  smooth();
  loadData();
  }

void draw() {
  background(255);
  for (int i = 0; i &lt; points.length; i++) {
    points[i].display();
  }
}

void loadData() {
  table = loadTable("Point_Class_Data.csv", "header");
  points = new Point[table.getRowCount()];

  for(int i = 0; i&lt; table.getRowCount(); i++) {
    TableRow row = table.getRow(i);
    float xpos = row.getFloat("MIXTO");
    xpos = map(xpos, 0, max(xpos), 0, width);
    points [i] =  new Point(xpos, height/2, 10, #FFCC00, #FFCC00, 175);
    println(xpos);
  }
}

class Point {

  float xpos;
  float ypos;
  color fill;
  color stroke;
  float alpha;
  float size;

  Point (float xpos_, float ypos_, float size_, color fill_, color stroke_, float alpha_) {
    xpos = xpos_;
    ypos = ypos_;
    size = size_;
    fill = fill_;
    stroke = stroke_;
    alpha = alpha_;
  }

  void display() {
    fill(fill,alpha);
    stroke(stroke,alpha);
    ellipse(xpos, ypos, size, size);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Looping over csv as nodes in datavisualization</title>
      <link>https://forum.processing.org/two/discussion/11399/looping-over-csv-as-nodes-in-datavisualization</link>
      <pubDate>Mon, 22 Jun 2015 08:51:42 +0000</pubDate>
      <dc:creator>RuudJoosten</dc:creator>
      <guid isPermaLink="false">11399@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone, I'm currently making a network visualization about dj's that play at festivals.
I have a CSV which lists those dj's per festival, the csv looks like this:</p>

<pre><code>Beat The Bridge,2012,12:00 - 13:15,Fanatic,,
Beat The Bridge,2012,13:15 - 14:30,Global Soundz,,
Beat The Bridge,2012,14:30 - 16:00,D-Block &amp; S-te-Fan,,
DefQon1,2012,11:00 - 12:00,Activator,,
DefQon1,2012,12:00 - 13:15,Isaac,,
DefQon1,2012,13:15 - 14:15,The Pitcher,,
Intents,2011,13:00 - 14:00,Dark-E,,
Intents,2011,14:00 - 15:15,Coone,,
Intents,2011,15:15 - 16:30,Isaac,,
</code></pre>

<p>I need to find a way to create a new node when the csv shows a new festival, but when it reads the same festival it needs to add 1 to a count, this also needs to happen per DJ.</p>

<p>I created a system that would count the festival but it will only work if my csv lists these festivals in order, so this wont work for the DJ's. I figured it might be usefull to create a 2-dimensional table but im not really sure how i can properly implement that in this code.</p>

<p>(Right now the "dj" nodes are not being created by a loop yet but are still static).</p>

<p>Any help would be greatly appriciated.</p>

<p>This is my main program:</p>

<pre><code>Node[] nodes = new Node[1]; //These will be the DJ nodes

festNode[] festnodes = new festNode[0]; //These are the Festival nodes

festData[] festdatas = new festData[0]; //This is just a helper to supply the Festival nodes with data


String[][] festrow;

float wait = 1000;
float last = 0;
int nc = 1;
int fc = 1;

String festival;
String year;
String time;
String dj;

Table table;
int festCount;
String theFestival;
int fci = 0;




void setup() {

  table = loadTable("test.csv", "header");

  println(table.getRowCount() + " total rows in table"); 

  //festnodes[0] = new festNode(random(width), random(height), 50, 50);

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

    festival = row.getString("Festival");
    year = row.getString("Year");
    time = row.getString("Time");
    dj = row.getString("DJ");


    festData fd = new festData(festival, dj);
    festdatas = (festData[]) append(festdatas, fd);



    if (fci == 0) {
      festCount = 1;
      festNode fn = new festNode(random(300, 1300), random(100, 700),festival, festCount);
      festnodes = (festNode[]) append(festnodes, fn);
      //print(festdatas[0].fest);
      fci++;
      print(fci-1);
    } else {
      //print("reachedelse");
      theFestival = festnodes[fci-1].fest;

      print(fci-1);

      if (theFestival.equals(festival) == true) {
        festCount ++;
        festnodes[fci-1].c = festCount;
      } else {
        festCount = 1;
        print("NEW ");
        festNode fn = new festNode(random(300, 1300), random(100, 700),festival, festCount);
        festnodes = (festNode[]) append(festnodes, fn);
        fci++;
      }
    }
   /*


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

    theFestival = festdatas[i].fest;

    if (theFestival.equals(festival) == true) {
        festCount ++;
        festdatas[i].count = festCount;
        print(" aye ");

      } else {
        festCount = 1;
        print(festdatas[i].fest);
        //print("NEW ");
        festNode fn = new festNode(random(300, 1300), random(100, 700),festival, festCount);
        festnodes = (festNode[]) append(festnodes, fn);
        fci++;
      }
    }
    */
  }


  ellipseMode(CENTER);
  size(1200, 600);

  nodes[0] = new Node(100, 250, 30, 30, 0);


}

void draw() {
  background(0);



  if (nc &lt; 10) {

    Node c = new Node(random(0, width), random(0, height), 30, 30, nc); 
    nodes = (Node[]) append(nodes, c);
    //println(nodes);
    //last = millis();
    nc++;
  }


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


    nodes[i].avoidSelf();
    //nodes[i].edgeSelf();
    nodes[i].edgeFestNode();
    nodes[i].moveToFestNode();
    nodes[i].moveNode(nodes[i]);
    nodes[i].display();
    //nodes[i].mouseDrag();
  }

  //line(xa, ya, xb, yb);
  stroke(255);



  for (int f=0; f&lt;festnodes.length; f++) {

    festnodes[f].display();
    festnodes[f].moveFestNode();
    festnodes[f].avoidSelf();
    festnodes[f].avoidWall();
    festnodes[f].displayName();
  }
}
</code></pre>

<p>These are my classes:</p>

<pre><code>/*----------------------------DJ NODES-----------------------------*/
class Node {
  float x;
  float y;
  float w;
  float h;          
  float distToNode;
  float col1 = random(255);
  float col2 = random(255);
  float col3 = random(255);
  float m = 0.01;
  int id;



  Node(float tempX, float tempY, float tempW, float tempH, int tempId) {

    x = tempX;
    y = tempY;
    w = tempW;
    h = tempH;
    id = tempId;
  }

  void display() {

    for (int i=0; i&lt;nodes.length; i++) {
      fill(col1, col2, col3);
      strokeWeight(0);
      //stroke(255, 0);
      ellipse(x, y, w, h);
    }
  }

  void avoidSelf() {

    for (int j=0; j&lt;nodes.length; j++) {

      if (nodes[j] != this) {

        distToNode = dist(x, y, nodes[j].x, nodes[j].y);
        if (distToNode &lt; 40) {

          PVector p = new PVector( nodes[j].x-x, nodes[j].y-y);
          p.limit(10);

          x-=p.x;
          y-=p.y;
        }
        //print(distToNode);
      }
    }
  }


  void edgeFestNode() {


    for (int j=0; j&lt;festnodes.length; j++) {

      distToNode = dist(x, y, festnodes[j].x, festnodes[j].y); 

      if (distToNode &lt; 200) {

        strokeWeight(12);
      } else if ((distToNode &lt; 400)) {
        strokeWeight(7);
      } else {
        strokeWeight(2);
      }

      stroke(col1, col2, col3);
      line(x, y, festnodes[j].x, festnodes[j].y);
    }
  }


  void moveToFestNode() {

    for (int j=0; j&lt;festnodes.length; j++) {

      distToNode = dist(x, y, festnodes[j].x, festnodes[j].y);
      if (distToNode &gt; 300) {

        x = lerp(x, festnodes[j].x, m);
        y = lerp(y, festnodes[j].y, m);
      }
    }
  }

  void moveNode(Node n) {

    //for (int f=0; f&lt;festnodes.length; f++) {
    //for (int j=0; j&lt;nodes.length; j++) {


    if  (mousePressed == true &amp;&amp; mouseX &lt; n.x+30 &amp;&amp; mouseX &gt; n.x-30 &amp;&amp; mouseY &lt; n.y+30 &amp;&amp; mouseY &gt; n.y-30 &amp;&amp; n == this) {

      x = mouseX;
      y = mouseY;
    }
  }




  /*----------------------------IGNORE - This is not being called upon-----------------------------*/
  void edgeSelf() {

    for (int j=0; j&lt;nodes.length; j++) {

      if (nodes[j] != this) {

        strokeWeight(2);
        stroke(col1, col2, col3);
        line(x, y, nodes[j].x, nodes[j].y);
      }
    }
  }
}


/*----------------------------FESTIVAL NODE-----------------------------*/

class festNode {
  float x;
  float y;
  float w;
  float h;          
  float distToNode;
  float col1 = random(255);
  float col2 = random(255);
  float col3 = random(255);
  String fest;  
  int c = 0;


  festNode(float tempX, float tempY, String tempFest, int tempCount ) {

    c = tempCount * 100;
    fest = tempFest;  
    x = tempX;
    y = tempY;
    //w = tempW;
    //h = tempH;
  }

  void display() {

    strokeWeight(0);
    stroke(255, 0);
    fill(col1, col2, col3);
    ellipse(x, y, c, c);
  }

  void moveFestNode() {

    for (int f=0; f&lt;festnodes.length; f++) {

      if (mousePressed == true &amp;&amp; mouseX &lt; festnodes[f].x+50 &amp;&amp; mouseX &gt; festnodes[f].x-50 &amp;&amp; mouseY &lt; festnodes[f].y+50 &amp;&amp; mouseY &gt; festnodes[f].y-50 &amp;&amp; festnodes[f] == this) {
        festnodes[f].x = mouseX;
        festnodes[f].y = mouseY;
      }
    }
  }

  void avoidSelf() {

    for (int j=0; j&lt;festnodes.length; j++) {

      if (festnodes[j] != this) {

        distToNode = dist(x, y, festnodes[j].x, festnodes[j].y);
        if (distToNode &lt; 100) {

          PVector p = new PVector( festnodes[j].x-x, festnodes[j].y-y);
          p.limit(10);

          x-=p.x;
          y-=p.y;
        }
        //print(distToNode);
      }
    }
  }

  void avoidWall() {

    if (x &lt; 0 || x &gt; width) {
      x = random(300,800);
    }
    if (y &lt; 0 || y &gt; height) {
      y = random(300, 600);
    }
  }


  void displayName() {

    textAlign(CENTER, CENTER);
    textSize(32);
    fill(0, 102, 153);
    text(fest, x, y); 

  }






}


/*----------------------------FESTIVAL DATA HELPER-----------------------------*/

class festData {
  String fest;
  String dj;  
  int count = 0;


  festData(String tempFest, String tempDj) {

    fest = tempFest;
    dj = tempDj;
  }


  void trackData() {
    count++;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to convert a csv file into arrays (one 1D and one 2D)?</title>
      <link>https://forum.processing.org/two/discussion/6668/how-to-convert-a-csv-file-into-arrays-one-1d-and-one-2d</link>
      <pubDate>Thu, 07 Aug 2014 07:56:08 +0000</pubDate>
      <dc:creator>kamca</dc:creator>
      <guid isPermaLink="false">6668@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I would like to convert a csv table looking like this (without blank lines inside)</p>

<p>header1, header2, header3</p>

<p>text1,2,3</p>

<p>text2,0,1</p>

<p>text3,0,0</p>

<p>into 2 arrays looking like this
{{2,3},{0,1},{0,0}} and this {text1, text2, text3}
Could anyone help me?
Thanks a lot
kamca</p>
]]></description>
   </item>
   <item>
      <title>loadTable from a .csv file an newlines</title>
      <link>https://forum.processing.org/two/discussion/6507/loadtable-from-a-csv-file-an-newlines</link>
      <pubDate>Sat, 26 Jul 2014 14:26:16 +0000</pubDate>
      <dc:creator>pierluigi_rotondo</dc:creator>
      <guid isPermaLink="false">6507@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I am loading from a .csv file the following table</p>

<pre><code>[...]
04.jpg,"line1\nline2\nline3"
05.jpg,"line1\nline2\nline3"
06.jpg,"line1\nline2\nline3"
07.jpg,"line1\nline2\nline3"
08.jpg,"line1\nline2\nline3"
[...]
</code></pre>

<p>with the following fragment of code</p>

<pre><code>  messagesFilename=language+".csv";
  Table table = loadTable(messagesFilename, "csv, newlines");      // i.e. file names 0.csv, 1.csv ...
  for (int index=0; index &lt; table.getRowCount (); index++) {
    imageFilename[index]=table.getString(index, 0);
    imageTitle[index]=table.getString(index, 1);

    // Print what just loaded
    println(imageFilename[index] + " " + imageTitle[index]);
  }
</code></pre>

<p>I would expect output of the println to take \n into consideration and to be in the form of</p>

<pre><code>[...]
04.jpg line1
line2
line3
05.jpg line1
line2
line3
[...]
</code></pre>

<p>but instead newlines (\n) are not properly interpreted and I get</p>

<pre><code>[...]
04.jpg line1\nline2\nline3
05.jpg line1\nline2\nline3
06.jpg line1\nline2\nline3
07.jpg line1\nline2\nline3
08.jpg line1\nline2\nline3
[...]
</code></pre>

<p>Any suggestions?</p>
]]></description>
   </item>
   </channel>
</rss>