Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

537
Vistas
Reading Excel File in Django uploaded using html form

I am learning django framework and trying to read an excel file

I want to upload file using html form(POST Method) and want to read in python for calculations so what should I do really confused ? Code Is Here form.html

<form method="POST" action="minmax_ans.html">{% csrf_tocken %}
   {{form.as_p}}
   <p><b><h2>Upload File</h2></b><p>
   <input type="file" name="file" value="{{ source.title }}">
   <input type="submit">
</form>

views.py

def upload_file(request):
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            handle_uploaded_file(request.FILES['file'])
            return HttpResponseRedirect('/success/url/')
    else:
        form = UploadFileForm()
    return render(request, 'upload.html', {'form': form})

I want to do some calculations using data in the file uploaded through html form if it is an excel file and display the result on result.html which I have not created yet because I cannot read the file

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Probably I would start by reading the Django documentation:
https://docs.djangoproject.com/en/1.10/topics/http/file-uploads/

To read the excel file you can use pandas:
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_excel.html

about 4 years ago · Santiago Trujillo Denunciar

0

You can do something like this

import pandas as pd
def handle_uploaded_file(f):
    pd.read_excel(f, index_col=0)

Pandas read_excel accepts argument io in str, ExcelFile, xlrd.Book, path object or file-like object.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda