def obterPapersDeProfessor(): professor = request.args.get('professor') if not professor: return Response(status=400) try: nomeArquivo = path.join("..", "data", "profs", "search", professor) + ".csv" csvfile = open(nomeArquivo) saida = '' with csvfile as csvfile: papers = csv.reader(csvfile, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True) for row in papers: saida += row[0] + ',' + row[1] + ',' + row[2] + ',' + row[ 3] + '\n' except IOError: return Response(status=404) except: return Response(status=500) return util.montaRespostaCSV(saida, "obterPapersDeProfessor")
def obterNumeroPublicacoesEmConferenciaEArea(): conferencia = request.args.get('conferencia') area = request.args.get('area') if not conferencia or not area: return Response(status=400) numPublicacoes = 0 try: with util.abreCSVAreaOutSufixo(area, "papers") as csvfile: papers = csv.reader(csvfile, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True) for row in papers: if (row[1] == conferencia.upper()): numPublicacoes += 1 except IOError: return Response(status=404) except: return Response(status=500) return util.montaRespostaCSV(str(numPublicacoes), "obterNumeroPublicacoesEmConferenciaEArea")
def obterNumerosProfessoresEmArea(): area = request.args.get("area") if not area: return Response(status=400) try: arquivo = util.abreCSVAreaOutSufixo(area,"profs") except IOError: return Response(status=404) conteudoArquivo = arquivo.read() arquivo.close() return util.montaRespostaCSV(conteudoArquivo, "obterNumerosProfessoresEmArea")
def obterNumeroProfessoresEmAreaEDepartamento(): area = request.args.get("area") departamento = request.args.get("departamento") if not area or not departamento: return Response(status=400) try: arquivo = util.abreCSVAreaOutSufixo(area,"profs") except IOError: return Response(status=404) achaDepartamento = filter(lambda linha: linha.find(departamento+",") == 0, arquivo) if not achaDepartamento: return Response(status=404) arquivo.close() return util.montaRespostaCSV(achaDepartamento[0], "obterNumeroProfessoresEmAreaEDepartamento")
def obterPapersEmArea(): area = request.args.get('area') if not area: return Response(status=400) try: saida = '' with util.abreCSVAreaOutSufixo(area, "papers") as csvfile: papers = csv.reader(csvfile, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True) for row in papers: saida += row[0] + ',' + row[2] + ',' + row[3] + ',' + row[ 4] + '\n' except IOError: return Response(status=404) except: return Response(status=500) return util.montaRespostaCSV(saida, "obterPapersEmArea")
def obterPapersEmAreaEmDepartamento(): area = request.args.get('area') departamento = request.args.get('departamento') if not area or not departamento: return Response(status=400) try: retorno = '' with util.abreCSVAreaOutSufixo(area, "papers") as csvfile: papers = csv.reader(csvfile, quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True) for row in papers: if (row[3] == departamento): retorno += row[0] + ',' + row[2] + ',' + row[ 3] + ',' + row[4] + '\n' except IOError: return Response(status=404) except: return Response(status=500) return util.montaRespostaCSV(retorno, "obterPapersEmAreaEmDepartamento")