summaryrefslogtreecommitdiff
path: root/parsecalldata.pde
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-02-06 15:04:23 +0000
committerTim Redfern <tim@eclectronics.org>2012-02-06 15:04:23 +0000
commit5e660544d27b2eec9e133e44c9f10c0cf0a51664 (patch)
treedd09b097f2cb7f0d63a148ed3bb9f2110695b653 /parsecalldata.pde
parent98a2dad141368b4d4f8efd2b6ef4dd2b4b1cb9bd (diff)
ready to load csv
Diffstat (limited to 'parsecalldata.pde')
-rw-r--r--parsecalldata.pde39
1 files changed, 39 insertions, 0 deletions
diff --git a/parsecalldata.pde b/parsecalldata.pde
new file mode 100644
index 0000000..0406194
--- /dev/null
+++ b/parsecalldata.pde
@@ -0,0 +1,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]));
+ }
+ }
+ }
+
+}