loadString
in
Programming Questions
•
3 years ago
Hello!
I am new here to the forum but I follow the discussions for a while now.
Today I joined because I have a question myself:
I am trying to make a start with an infographic.
On a single line in the text file with the stats there are 3 important things.
this is what it looks like:
- 1. Calibre - 3886
- 2. Legowelt - 3569
- 3. Logistics - 2309
- 4. Radiohead - 2099
the first number is the ranking followed by the artist and then the total play count.
How can I put this info in a string?
I want the ranking to be the order and the the total play count the height for the bars for example.
this is my code so far:
- void setup() {
- size(1200,600);
- background(0);
- smooth();
- textFont( loadFont( "GiorgioSans-Light-24.vlw" ) );
- barGraph();
- }
- void barGraph() {
- String[] stats = loadStrings("stats_artists.txt");
- //String[] stats = splitTokens(statistics, "1 ");
- for(int i = 0; i < stats.length; i++) {
- text("" + stats[i] + "", random(1200),random(600));
- }
- }
But the problem and thus the question here is how the extract the 3 different kinds of info from the single lines (ranking/artist/total play count)
Can anyone help me out a little with this?
Great thanks in advance!
1