def index(request): plots = defaultdict(list) with open('/home/sachin/mysite/plots/static/plots/plots.pickle', 'rb') as handle: plots = pickle.load(handle) with open('/home/sachin/mysite/plots/static/plots/scores.pickle', 'rb') as handle: scores = pickle.load(handle) if request.method == 'POST': # X = plots['all']; # T = [scores[i] for i in X]; # T = [0 if np.isnan(x) else x for x in T]; # Y= [x for (t,x) in sorted(zip(T,X),reverse=True)]; # Y = map(str, Y) # T = sorted(T,reverse=True) if (not request.FILES): f = 'wine.csv' else: f = request.FILES['myfile'] fs = request.FILES['myschema'] with open('file.csv', 'wb+') as destination: for chunk in f.chunks(): destination.write(chunk) with open('schema.csv', 'wb+') as destination: for chunk in fs.chunks(): destination.write(chunk) Generate.main("schema.csv", "prototype.csv") Groupby.main("file.csv", "schema.csv") Genplots.main("file.csv", "experiment.csv", "groups.csv") p = list(range(settings.count)) p = map(str, p) # return render_to_response("plots/index.html", {'plots_scores': zip(Y,T), 'filename' : f}) return render_to_response("plots/index.html", { 'plots': p, 'filename': f }) if request.method == 'GET': # If the form is submitted f = '' search_query = request.GET.get('search_box', None) X = plots[str(search_query).lower()] T = [scores[i] for i in X] T = [0 if np.isnan(x) else x for x in T] Y = [x for (t, x) in sorted(zip(T, X), reverse=True)] Y = map(str, Y) T = sorted(T, reverse=True) return render_to_response( 'plots/index.html', # {'plots': plots[search_query]}) { 'plots_scores': zip(Y, T), 'filename': f })
def index(request): plots = defaultdict(list); with open('/home/sachin/mysite/plots/static/plots/plots.pickle', 'rb') as handle: plots = pickle.load(handle) with open('/home/sachin/mysite/plots/static/plots/scores.pickle', 'rb') as handle: scores = pickle.load(handle) if request.method == 'POST': # X = plots['all']; # T = [scores[i] for i in X]; # T = [0 if np.isnan(x) else x for x in T]; # Y= [x for (t,x) in sorted(zip(T,X),reverse=True)]; # Y = map(str, Y) # T = sorted(T,reverse=True) if(not request.FILES): f='wine.csv'; else: f=request.FILES['myfile'] fs=request.FILES['myschema'] with open('file.csv', 'wb+') as destination: for chunk in f.chunks(): destination.write(chunk) with open('schema.csv', 'wb+') as destination: for chunk in fs.chunks(): destination.write(chunk) Generate.main("schema.csv", "prototype.csv") Groupby.main("file.csv", "schema.csv") Genplots.main("file.csv", "experiment.csv", "groups.csv") p=list(range(settings.count)) p=map(str,p) # return render_to_response("plots/index.html", {'plots_scores': zip(Y,T), 'filename' : f}) return render_to_response("plots/index.html", { 'plots':p, 'filename' : f}) if request.method == 'GET': # If the form is submitted f=''; search_query = request.GET.get('search_box', None) X = plots[str(search_query).lower()]; T = [scores[i] for i in X]; T = [0 if np.isnan(x) else x for x in T]; Y= [x for (t,x) in sorted(zip(T,X),reverse=True)]; Y = map(str, Y) T = sorted(T,reverse=True) return render_to_response('plots/index.html', # {'plots': plots[search_query]}) {'plots_scores': zip(Y,T), 'filename' : f})
def index(request): if (request.is_ajax()): print("reached here") schema = request.POST.get('schema', '') print(schema) sdict = ast.literal_eval(schema) print(type(sdict)) for key, value in sdict.items(): print(key) print(value) with open('schema.csv', 'wt+') as destination: csvwriter = csv.writer(destination) csvwriter.writerow(["name", "type"]) for key, value in sdict.items(): csvwriter.writerow([key, value]) with open('file.txt', 'r') as f: filename = f.readlines() Generate.main("schema.csv", "prototype.csv") Groupby.main(filename[0], "schema.csv") Genplots.main(filename[0], "experiment.csv", "groups.csv") return HttpResponse([]) elif (request.method == 'POST'): settings.count = 0 if (not request.FILES): plotdata = PlotData.objects.all() return render_to_response("index.html", {'plotdata': plotdata}) else: f = request.FILES['myfile'] with open('file.txt', 'w') as dest: dest.write(f.name) with open(f.name, 'wb+') as destination: for chunk in f.chunks(): destination.write(chunk) with codecs.open(f.name, 'r', encoding="utf-8") as f: d_reader = csv.DictReader(f) headers = d_reader.fieldnames plotdata = PlotData.objects.all() return render_to_response("index.html", { 'names': headers, 'plotdata': plotdata }) plotdata = PlotData.objects.all() return render_to_response("index.html", {'plotdata': plotdata})
def main(argv): CreateSchema.main(argv) Generate.main("Schema.csv", "prototype.csv") Groupby.main(argv, "Schema.csv") Genplots.main(argv, "experiment.csv", "groups.csv")