def main(): select=1 print("* * * Welcome To The Album Store!!! * * * ") #We Can Select menu while select != 0: print("\n 1.List of Album\n","2.Modify Album\n","3.Search Album\n","0.EXIT") select =int( input("\n please select contents: ")) if select == 1 : r=read() r.list() elif select ==2 : print("\n 1.Add Album\n","2.Modify Album\n","3.Delete Album\n","0.BacK") inselect =int(input("\n please select contents: ")) if inselect ==1 : w.addAlbum() elif inselect ==2 : w.modifyAlbum() elif inselect == 3: w.deleteAlbum() elif select ==3 : r=read() print("\n 1.Search With Singer\n","2.Search With Genre\n","0.BacK") inselect =int(input("\n please select contents: ")) if inselect ==1 : r.searchwithSingername() elif inselect ==2 : r.searchwithgenre()
def see_question_answers(request, question): #load csv df = utils.get_whole_survey() #load questionchoices txt file2_ = open( os.path.join(settings.BASE_DIR, 'clusters/RSQquestionchoices.txt')) dic_source = rt.read(file2_) about = dic_source['about'] questions_txt = dic_source['questions'] file2_.close() charts = [] try: chart = get_question_chart(df, questions_txt[question]) charts.append(chart) except KeyError: question_obj = questions_txt[question] choices = question_obj.choices letters = choices.keys() for letter in letters: try: chart = get_question_chart(df, question_obj, letter=letter, choice=choices[letter]) charts.append(chart) except KeyError: continue context = { 'charts': charts, 'question': question, 'about': about, } return render(request, 'clusters/question.html', context)
def group_compare(request): cluster = get_object_or_404(Cluster, pk=3) #load csv into pandas.DataFrame dic = rc.filter_by_cluster(utils.get_whole_survey(), cluster) df = dic['df'] size_str = "%d / %d" % (len(df.index), dic['orig_size']) clusters_dict = clustering.get_subclusters_length(cluster, dic['df']) #load questions textfile into list file2_ = open( os.path.join(settings.BASE_DIR, 'clusters/RSQquestionchoices.txt')) dic_source = rt.read(file2_) about = dic_source['about'] questions_txt = dic_source['questions'] file2_.close() #get cluster questions as strings questions_strs = get_questions_as_str(questions_txt) #get charts charts = get_charts(df, questions_txt, cluster, 'a') context = { 'cluster': cluster, 'charts': charts, #'compare_chart': compare_chart, 'df_size': size_str, #no of rows in df 'questions_strs': questions_strs, 'about': about, 'subcluster_values': list(clusters_dict.values()), 'num_of_clusters': cluster.num_of_clusters, 'compare': False, } return render(request, 'clusters/group_compare.html', context)
def get_questions_txt(): global SURVEYTXT if SURVEYTXT is None: with open( os.path.join(settings.BASE_DIR, 'clusters/RSQquestionchoices.txt')) as f: SURVEYTXT = rt.read(f) return SURVEYTXT
def get_wards(): """ follows singleton design pattern, loads from file only if WARD is empty """ global WARD if bool(WARD) == False: with open( os.path.join(settings.BASE_DIR, 'clusters/RSQquestionchoices.txt')) as f: dic_source = rt.read(f) WARD = dic_source['questions']['WARD'].choices return WARD
def survey_questions(request): #load csv df = utils.get_whole_survey() #load questionchoices txt file2_ = open( os.path.join(settings.BASE_DIR, 'clusters/RSQquestionchoices.txt')) dic_source = rt.read(file2_) about = dic_source['about'] questions_txt = dic_source['questions'] file2_.close() context = { 'questions': questions_txt.values(), 'about': about, } return render(request, 'clusters/survey.html', context)
def json1(request, cluster_id, subcluster_id): """ used for map """ cluster = get_object_or_404(Cluster, pk=cluster_id) #load csv into pandas.DataFrame dic = rc.filter_by_cluster(utils.get_whole_survey(), cluster) df = dic['df'] if subcluster_id != 'a': df = clustering.get_subclusters(cluster, df)[int(subcluster_id)] #load questions textfile into list file2_ = open( os.path.join(settings.BASE_DIR, 'clusters/RSQquestionchoices.txt')) dic_source = rt.read(file2_) about = dic_source['about'] questions_txt = dic_source['questions'] file2_.close() output = rc2.get_data_for_map(df, questions_txt['WARD']) return JsonResponse(output, safe=False)
def detail(request, cluster_id): cluster = get_object_or_404(Cluster, pk=cluster_id) #load csv into pandas.DataFrame dic = rc.filter_by_cluster(utils.get_whole_survey(), cluster) df = dic['df'] group_size = len(df.index) survey_size = dic['orig_size'] if group_size == 0: return render(request, 'clusters/emptygroup.html', {'cluster': cluster}) clusters_dict = clustering.get_subclusters_length(cluster, dic['df']) #load questions textfile into list file2_ = open( os.path.join(settings.BASE_DIR, 'clusters/RSQquestionchoices.txt')) dic_source = rt.read(file2_) file2_.close() about = dic_source['about'] questions_txt = dic_source['questions'] #get cluster questions as strings questions_strs = get_questions_as_str(questions_txt) #get charts charts = get_charts(df, questions_txt, cluster, 'a') context = { 'cluster': cluster, 'subcluster_id': 'a', 'charts': charts, 'group_size': group_size, #no of rows in df 'survey_size': survey_size, 'questions_strs': questions_strs, 'about': about, 'subcluster_values': list(clusters_dict.values()), 'num_of_clusters': cluster.num_of_clusters, 'compare': False, } return render(request, 'clusters/detail.html', context)
def subcluster_detail(request, cluster_id, subcluster_id): cluster = get_object_or_404(Cluster, pk=cluster_id) #load csv into pandas.DataFrame dic = rc.filter_by_cluster(utils.get_whole_survey(), cluster) df = dic['df'] df = clustering.get_subclusters(cluster, df)[0] #dicitonary size_str = "%d / %d" % (len(df.index), dic['orig_size']) clusters_dict = clustering.get_subclusters_length(cluster, dic['df']) #load questions textfile into list file2_ = open( os.path.join(settings.BASE_DIR, 'clusters/RSQquestionchoices.txt')) dic_source = rt.read(file2_) about = dic_source['about'] questions_txt = dic_source['questions'] file2_.close() #get cluster questions as strings questions_strs = get_questions_as_str(questions_txt) #get charts charts = get_charts(df, questions_txt, cluster, subcluster_id) context = { 'cluster': cluster, 'subcluster_id': subcluster_id, 'charts': charts, 'group_size': len(df.index), #no of rows in df 'survey_size': dic['orig_size'], 'questions_strs': questions_strs, 'about': about, 'subcluster_values': list(clusters_dict.values()), 'num_of_clusters': cluster.num_of_clusters, 'issubcluster': True, } return render(request, 'clusters/detail.html', context)
''' Created on 2019. 12. 4. @author: KMU_USER ''' from readtxt import read r = read() class write: def modifyAlbum(self): print(r.bar) albumname = input("\nPlease enter Album's Name Want To Modify : ") modifyed = 0 for num in r.index: if albumname.upper() == num[0].upper(): modifyAlbumname = input("Enter the New Album Name: ") modifyAlbuumsinger = input("Enter the New Album Singer: ") modifyAlbumgenre = input("Enter the New Album Genre: ") num[0] = modifyAlbumname num[1] = modifyAlbuumsinger num[2] = modifyAlbumgenre.upper() modifyed = 1 print(r.bar) if modifyed == 1: print("\nSuccessfully Modified!!!") else: print("\nSorry!i Can't Find Album has that name!!!\n")