예제 #1
0
def test7():
	#fetch list of countries and a dictionary of countries mapped with rows from csv for group1
	country, country_result = util.country_group2()
	result=util.group2()
	labels = util.cluster_user_data(result)
	x1=[]

	len_cluster=3
	j1=-1
	country1=[]
	for j  in range(len(country)):
		country_item=country[j]

		if len(country_result[country_item]) > 10:
			country1.append(country[j])
			result=util.group2()
			labels = util.cluster_user_data(country_result[country_item])
			j1=j1+1
			result1=util.split_user_data(country_result[country_item], labels)
			for i in range(3):
				#print(i)
				#print(j)
				x1.append([])
				x1[j1].append(result1[i])



	len_country1=len(country1)
	#print(len_country)
	#print(country)
	return render_template('index1.html', labels_html=labels, column_html=column_names, data_html=result1[0], x1=x1, len_country=len_country1, country=country1)
예제 #2
0
def test2():
    result = util.group2()
    labels = util.cluster_user_data(result)
    return result
예제 #3
0
def test2():
	result = util.group2()
	return render_template('index.html', column_html=column_names, data_html=result)
예제 #4
0
def query_survey_results4(country_name=''):

    country, country_result = util.country_group3()
    result = util.group3()
    labels = util.cluster_user_data(result)
    x1 = []

    len_cluster = 3
    j1 = -1
    country1 = []
    for j in range(len(country)):
        country_item = country[j]

        if len(country_result[country_item]) > 10:
            country1.append(country[j])
            result = util.group3()
            labels = util.cluster_user_data(country_result[country_item])
            j1 = j1 + 1
            result1 = util.split_user_data(country_result[country_item],
                                           labels)
            for i in range(3):
                #print(i)
                #print(j)
                x1.append([])
                x1[j1].append(result1[i])
                # print(j1)
                # print(i)
                # print(x1[j1][i])
    group3 = x1
    #print(group3)

    country, country_result = util.country_group1()
    #print(country_result)
    result = util.group1()
    labels = util.cluster_user_data(result)
    x1 = []

    len_cluster = 3
    j1 = -1
    country1 = []
    for j in range(len(country)):
        country_item = country[j]

        if len(country_result[country_item]) > 10:
            country1.append(country[j])
            result = util.group1()
            labels = util.cluster_user_data(country_result[country_item])
            j1 = j1 + 1
            result1 = util.split_user_data(country_result[country_item],
                                           labels)
            for i in range(3):
                #print(i)
                #print(j)
                x1.append([])
                x1[j1].append(result1[i])
    group1 = x1
    #print(group1)
    country, country_result = util.country_group2()
    result = util.group2()
    labels = util.cluster_user_data(result)
    x1 = []

    len_cluster = 3
    j1 = -1
    country1 = []
    for j in range(len(country)):
        country_item = country[j]

        if len(country_result[country_item]) > 10:
            country1.append(country[j])
            result = util.group2()
            labels = util.cluster_user_data(country_result[country_item])
            j1 = j1 + 1
            result1 = util.split_user_data(country_result[country_item],
                                           labels)
            for i in range(3):
                #print(i)
                #print(j)
                x1.append([])
                x1[j1].append(result1[i])

    group2 = x1
    #print(group2)
    country, country_result = util.country_group4()
    result = util.group4()
    labels = util.cluster_user_data(result)
    x1 = []

    len_cluster = 3
    j1 = -1
    country1 = []
    for j in range(len(country)):
        country_item = country[j]

        if len(country_result[country_item]) > 10:
            country1.append(country[j])
            result = util.group4()
            labels = util.cluster_user_data(country_result[country_item])
            j1 = j1 + 1
            result1 = util.split_user_data(country_result[country_item],
                                           labels)
            for i in range(3):
                #print(i)
                #print(j)
                x1.append([])
                x1[j1].append(result1[i])
                # print(j1)
                # print(i)
                # print(x1[j1][i])

    group4 = x1
    #print(group4)
    dictionary_usa = {'country': ['Unites States Of America']}
    dictionary_romania = {'country': ['Romania']}
    dictionary_switzerland = {'country': ['Switzerland']}
    for i in range(2):
        for j in range(3):
            if (group1[i][j][1][1] == 'USA'):
                dictionary_usa['group1' + 'cluster' + str(j)] = [group1[i][j]]
            else:
                dictionary_romania['group1' + 'cluster' +
                                   str(j)] = [group1[i][j]]

    for i in range(1):
        for j in range(3):
            if (group2[i][j][1][1] == 'USA'):
                dictionary_usa['group2' + 'cluster' + str(j)] = [group2[i][j]]
            else:
                dictionary_romania['group2' + 'cluster' +
                                   str(j)] = [group2[i][j]]

    for i in range(3):
        for j in range(3):
            if (group3[i][j][1][1] == 'USA'):
                dictionary_usa['group3' + 'cluster' + str(j)] = [group3[i][j]]
            else:
                if (group3[i][j][1][1] == 'Switzerland'):
                    dictionary_switzerland['group3' + 'cluster' +
                                           str(j)] = [group3[i][j]]
                else:
                    dictionary_romania['group3' + 'cluster' +
                                       str(j)] = [group3[i][j]]

    for i in range(2):
        for j in range(3):
            if (group4[i][j][1][1] == 'USA'):
                dictionary_usa['group4' + 'cluster' + str(j)] = [group4[i][j]]
            else:
                dictionary_romania['group4' + 'cluster' +
                                   str(j)] = [group4[i][j]]
    dictionary_usa = str(dictionary_usa)
    dictionary_usa = dictionary_usa.replace('(', '[')
    dictionary_usa = dictionary_usa.replace(')', ']')
    dictionary_usa = eval(dictionary_usa)

    dictionary_romania = str(dictionary_romania)
    dictionary_romania = dictionary_romania.replace('(', '[')
    dictionary_romania = dictionary_romania.replace(')', ']')
    dictionary_romania = eval(dictionary_romania)

    dictionary_switzerland = str(dictionary_switzerland)
    dictionary_switzerland = dictionary_switzerland.replace('(', '[')
    dictionary_switzerland = dictionary_switzerland.replace(')', ']')
    dictionary_switzerland = eval(dictionary_switzerland)
    #print(group1[0][0])
    return json.dumps(dictionary_romania)