I am trying to resonate excel file with Panda's data representation in Django templates. I've tried quite a few things but I can't get header columns indexed as 1. Pandas starts indexing below the header columns. If will be great help if someone can guide me. Below is the code I am trying to resonate with Excel sheet exactly.
def home(request):
template = 'home.html'
form = ExcelUpload(request.POST or None, request.FILES)
if request.method == 'POST':
if form.is_valid():
excelfile = ExcelFileUpload(uploaded_file = request.FILES['uploaded_file'])
excelfile.save()
data = pd.read_excel(excelfile.uploaded_file.path, header=None)
new_header = data.iloc[0]
data = data[1:]
data.columns = new_header
data_to_html = data.to_html
return render(request, template, {'form':form, 'data_to_html':data_to_html})
else:
form = ExcelUpload()
return render(request, template, {'form': form})
My excel file shows 20 entries indexed in the
but when I parse it to web it shows me 19 entries indexed like this
. I need help to convert headers into index 1 so my excel file and web sheet resonates. Thanks.