Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

534
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!