summaryrefslogtreecommitdiff
path: root/parsecalldata.pde
blob: 04061945af0532f0822a4211b364518a12a2c270 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//BT IRELAND MTM,Destination CID Name,VIA,Calls,MINS,ALOC,% User,ASR,NER 02

class country {
  String name;
  float calls,mins;
  country(String n,String c,String m){
    name=n;
    calls=Float.valueOf(c.trim()).floatValue();
    mins=Float.valueOf(m.trim()).floatValue();
  }
  void addnetwork(String c,String m) {
    calls+=Float.valueOf(c.trim()).floatValue();
    mins+=Float.valueOf(m.trim()).floatValue();
  }
  void printOut() {
    println(name+" "+calls+" "+mins);
  }
}

class calldata {
  
  Vector<country> countries = new Vector<country>();
  calldata(String[][] data) {
    println("parsing "+data.length+" entries");
    //detect number of countries
    int num=0;
    countries.add(new country(data[0][1],"0","0"));
    for (int i=0; i < data.length; i++) { 
      if (data[i][1].substring(0, 2).equals(countries.lastElement().name.substring(0, 2))) {
        countries.lastElement().addnetwork(data[i][3],data[i][4]);
      }
      else {
        countries.lastElement().printOut();
        countries.add(new country(data[i][1],data[i][3],data[i][4]));
      }      
    }
  }
  
}