# Data

Notes:
The election was aborted and war broke out again.


Notes:
President was elected by the Supreme Soviet


Name:
Union for the Triump of Democratic Renewal


Name:
Coalition for a Whole and Democ. Bos. and Herz.


Notes:
Pres. Neves shared his power with parliament


Notes:
Gen. Lamizana kept power in a transition period


Notes:
The elected president was killed and replaced


Notes:
President elected by an electoral college


Name:
Gen. Tómas Guardia's provisional government


Name:
Vice president Cáceres' provisional government


Name:
Ethiopian People's Revolutionary Democratic Front


Name:
Alliance for Patriotic Reorientation and Construct


Name:
Occupied by Germany, Italy, and Bulgaria


Name:
African Party for Independence of Guinea and Cape


Name:
National Small Farmers and Farmworkers' Party


Name:
Christian Small Farmers',Farmworkers' and Bourgeoi


Notes:
Sukarno dissolved the parliament and reintroduced


Name:
Joint Secretariat of Functional Groups (Golkar)


Name:
Ministerial and Opposition Liberals and National B


Name:
United Democratic Fatherland Front (UDFF)


Name:
Lao People's Revolutionary Party and allies


Name:
Provisional government of  J. B. Ceballas


Name:
Mongolian People's Revolutionary Party (communists


Name:
Mongolian People's Revolutionary Party (MPRP)


Name:
Front for the Defense of Constitutional Institutio


Name:
South West Africa People's Organization (SWAPO)


Notes:
Rana family established an autocratic system and r


Notes:
King Mahendra suspended the 1959 democratic consti


Notes:
Civil war and the invasion of Walker in 1854-57


Name:
The provisional government of Tómas Martinez


Name:
Sandinista National Front's provisional government

Notes:
Civil war and the Sandinista National Front's prov


Notes:
President Diori was overthrown by a military coup


Name:
National Movement for a Development Society


Name:
National Union of Independents for Democratic Rene


Notes:
The sultan rules with the assistance of a cabinet


Name:
General Zia ul-Haq's military government


Notes:
After Francia's dead in 1840, provisional governme


Name:
Provisional governments, presidents, and juntas


Notes:
President Marcos decreed martial law throughout th


Notes:
The coup d'état of October 5, 1910, made Portugal


Notes:
Traditional sheikhdom without direct elections.


Name:
Human Rights Protection Party and supporters


Name:
Movement for the Liberation of Sao Tome and Princi


Name:
Democratic Convergence Party - Reflection Group


Name:
Sao Tome and Principe Liberation Movement - Social


Notes:
The army took power after the 1967 parliamentary e


Name:
Group for National Unity and Reconciliation


Notes:
Coup d'état and the military dictatorships of Prim


Notes:
Syria constituted the Northern Region of the Unite


Name:
United Thai People's Party and its supporters


Notes:
Prime Minister, Gen. Ben Ali, deposed President Bo


Name:
Young Turks' of Union and Progress Party


Notes:
Turkey was ruled by two competing governments


Name:
Provisional government of E. L. Contreras


Name:
Members of the Consultative Council of the former


Vanhanen name:
Yemen, People's Democratic Republic of (South)


Name:
Yemen Socialist Party and independent supporters


Name:
Coalition: Socialist Party of Serbia and allied gr


Name:
Coalition: Socialist party of Serbia and allied gr


Name:
United National Independence Party (UNIP)


Name:
Zimbabwe African National Union - Patriotic Front


# Source code

comment:
This is the code that we used to create the index.

code:
# Python-script to generate the Polyarchy index from the Vanhanen data base
# Written by Havard Strand, PRIO, 07/08-00
# 
# Homepage: www.svt.ntnu.no/iss/data/vanhanen
# Information: hs@prio.no
#
# Requirements:
# Python: www.python.org
# ODBC: http://www.microsoft.com/data/odbc/default.htm
# The database must be liked to an ODBC datasource as 'vanhanen', and
# you will need the latest Access drivers for ODBC.
# The program will create an new table 'indeks', but it will not overwrite
# the existing 'index'


import DateTime, dbi, odbc, string, regsub

Parexec=5


# Procedure for fetching all observations from a given country, and to keep the
# connection to the database in order.

class GetCountries:
    def __init__(self, sourcename, tablename):
        self.base=odbc.Windows.Connect(sourcename,clear_auto_commit=0)
        self.cursor=self.base.cursor()
        self.table=tablename

# The actual procedure fetching the observations        
    def catch(self, country):
        SQLstring="SELECT * FROM "+self.table+" WHERE [V country] = " + country  
        self.cursor.execute(SQLstring)
        result=self.cursor.fetchall()
        return result

# A small procedure for retreiving the year from a date object
def getyear(indate):
    return int(string.split(str(indate),'-')[0])

Inst=GetCountries('vanhanen','Data')        # Initializing the data source

#Preparing the database for output
outbase=odbc.Windows.Connect('vanhanen',clear_auto_commit=0)
outcursor=outbase.cursor()
try: outcursor.execute("DROP TABLE indeks")
except: pass
outcursor.execute("CREATE TABLE indeks (year INTEGER, country INTEGER, comp DOUBLE, part DOUBLE, id DOUBLE, cow INTEGER, abb CHAR(4))")


for country in range(1,188):        #The routine is run for each of the 187 countries
    Obs=Inst.catch(str(country))    
    currexec, currparl=None, None
    Summ, Exec, Parl=[], [], []
    for line in Obs:                #Eace observation is either an executive or parliamentary observation,
        if line[Parexec]==1:        #so we got to separate them into two different arrays
            Exec.append(line)
        elif line[Parexec]==0:
            Parl.append(line)

    #Unfortuneatly, the arrays are sorted wrong, so we need to flip both arrays
        
    Parl.reverse()
    Exec.reverse()

    Liste=[]                        #The final list object, from which the country-year list is written

    #While there are objects left, either parliamentary or execeutive observations, we continue
    #The logic of the following code is that there is always a current executive and a current
    #parliamentary observation. One of them might be 'None', empty, which indicates that one part
    #of the government dominates. Each time, the oldest reminding observations replaces one of the
    #two currents, or if there are two events happening at the same day, both observations are replaced.
    #If an observation har 100% influence (Weight=100) or the observation is under foreign influence
    #(Weight=-99), the parallell observation is set to none.
    #At the end, the two parallell observations are put together, and a new, unified observation is made.
    #This observation is added to the Liste object and handeled in the last part of the program.

    WEIGHT=10
    ENDDATE=8
    STARTDATE=6
    PARTISIPATION=16
    COMPETITION=13
    
    while not(Exec==[]) or not(Parl==[]):   
        if Exec==[] or Parl==[]:
            if Exec==[]:
                currparl=Parl.pop()   
                if (currparl[WEIGHT]==100) or (currparl[WEIGHT]==-99):
                    currexec=None
                startdate=currparl[STARTDATE]                                   
            elif Parl==[]:
                currexec=Exec.pop()
                if (currexec[WEIGHT]==100) or (currexec[WEIGHT]==-99):
                    currparl=None
                startdate=currexec[STARTDATE]
        else:
            if Exec[len(Exec)-1][STARTDATE]<Parl[len(Parl)-1][STARTDATE]:
                currexec=Exec.pop()
                if (currexec[WEIGHT]==100) or (currexec[WEIGHT]==-99):
                    currparl=None
                startdate=currexec[STARTDATE]
            elif Exec[len(Exec)-1][STARTDATE]>Parl[len(Parl)-1][STARTDATE]:
                currparl=Parl.pop()
                if (currparl[WEIGHT]==100) or (currparl[WEIGHT]==-99):
                    currexec=None
                startdate=currparl[STARTDATE]
            elif Exec[len(Exec)-1][STARTDATE]==Parl[len(Parl)-1][STARTDATE]:
                currparl=Parl.pop()                
                currexec=Exec.pop()                
                startdate=currparl[STARTDATE]
        try:
            if currparl[ENDDATE]<currexec[ENDDATE]:
                enddate=currparl[ENDDATE]
                cow, abb, fnm=currparl[2:5]
            else:
                enddate=currexec[ENDDATE]
                cow, abb, fnm=currexec[2:5]
        except:
            if currparl==None:
                enddate=currexec[ENDDATE]
                cow, abb, fnm=currexec[2:5]
            else:
                enddate=currparl[ENDDATE]
                cow, abb, fnm=currparl[2:5]
        if enddate==None:
            enddate=DateTime.Date(1998,12,31)
        Summ=[country, startdate, enddate]
        try: Summ.append((currexec[WEIGHT]*(100-currexec[COMPETITION])/100)+(currparl[WEIGHT]*(100-currparl[COMPETITION])/100))
        except:
            try: Summ.append(currexec[WEIGHT]*(100-currexec[COMPETITION])/100)
            except: Summ.append(currparl[WEIGHT]*(100-currparl[COMPETITION])/100)
                    
        try: Summ.append((currexec[WEIGHT]*currexec[PARTISIPATION]/100)+(currparl[WEIGHT]*currparl[PARTISIPATION]/100))
        except:
            try: Summ.append(currexec[WEIGHT]*currexec[PARTISIPATION]/100)
            except: Summ.append(currparl[WEIGHT]*currparl[PARTISIPATION]/100)
        #Prevent competition from becoming larger than 70.
        if Summ[3]>70:
            Summ[3]=70
        #calculation of the democratization value.    
        Summ.append(Summ[3]*Summ[4]/100)
        try: weight=currparl[WEIGHT]
        except: weight=0
        try: weight=weight+currexec[WEIGHT]
        except: pass
        Summ.append(weight)
        Summ.append(cow)
        Summ.append(abb)
        Summ.append(fnm)
        Liste.append(Summ)
    output={}
    #For each observation in Liste, we try to put the democracy values into the output object.
    #If there already is an observation recorded for this year, we use the highest value. This is
    #fairly easy to adjust if you would like to recalculate the index 
    for evt in Liste:
        if not evt[6]<=0:
            for year in range(getyear(evt[1]), getyear(evt[2])+1):
                if not year in output.keys():
                    output[year]=[evt[0],evt[3],evt[4],evt[5],evt[6],evt[7],evt[8]]
                else:
                    if output[year][3]<evt[5]: #This is the line deciding what observation to use if
                        # there are more than one observation per year.
                        output[year]=[evt[0],evt[3],evt[4],evt[5],evt[6],evt[7],evt[8]]

    #The last lines moves whatever is in the output-object into the database.                    
    for key in output.keys():
        SQL="INSERT into indeks values (%3d, %3d, %0.2f, %0.2f, %0.2f, %3d, '%s')" % (key, output[key][0], output[key][1], output[key][2], output[key][3], output[key][5], output[key][6])
        outcursor.execute(SQL)


# Vanhanen Country Table

vanhanen name:
Yemen, People's Democratic Republic of (South)


