bzr branch
http://gegoxaren.bato24.eu/bzr/%2Bjunk/Dataanalys
11
by Gustav Hartvigsson
added the beginings of the "plotter" |
1 |
#!/usr/bin/env python3.1
|
2 |
"""
|
|
3 |
This file contains the plotting funcioton that plots the data into a bar graph.
|
|
4 |
"""
|
|
5 |
import sys |
|
6 |
import sqlite3 |
|
7 |
import numpy |
|
8 |
||
9 |
class plotDB(object): |
|
10 |
def __init__(self): |
|
11 |
##This array is passed to getDB
|
|
12 |
self.nameArray = ["gudar", "spoken", "religos", "sekulart" ,"vegan" ,"mars" ,"globaluppvarmning" ,"manen" ,"motion" ,"sund" ,"deprimerad_host" ,"sno" ,"oppet" ,"dodsstraff" ,"kvinnors_rattigheter" ,"abort", "kvinnors_kropp", "deprimerad_var" ,"gast_sverige" ,"fodd_sverige" ,"foraldrar_sverige" ,"komentarer"] |
|
13 |
||
14 |
GetData = getDB(self.nameArray) |
|
15 |
||
16 |
def doPlot(self): |
|
17 |
CountArray = GetData.doGet() |
|
18 |
||
19 |
||
20 |
||
21 |
class getDB(object): |
|
22 |
""" returns an array of counts of from the database""" |
|
23 |
def __init__(self, iarray): |
|
24 |
self.conn = sqlite3.connect("./awnsers.sqlite") |
|
25 |
self.db = self.conn.cursor() |
|
26 |
||
27 |
self.nameArray = iarray |
|
28 |
self.countArray = list() |
|
29 |
||
30 |
self.countStart = "select count(*) from awnsers where(" |
|
31 |
self.countEnd = " == 1);" |
|
32 |
||
33 |
def doGet(self): |
|
34 |
for name in self.nameArray: |
|
35 |
getItem = self.db.execute(self.countStart + str(name) + self.countEnd ) |
|
36 |
||
37 |
for item in getItem: |
|
38 |
self.countArray.append(item) |
|
39 |
||
40 |
return self.countArray |
|
41 |