Avoid unicode characters when loading an Excel file

Hello,

I have a problem with a simple import of a file after a form on my template.
I want the user to import an XLS file which I then convert to tuple for use.

Here is the template:

 <form method="post" enctype="multipart/form-data">{% csrf_token %}
    <input type="file" name="InputFile" accept=".xls">
    <input type="Submit" value="loadFile">                                            
</form>

And in the view :

import pandas as pd

excelFile = request.FILES.get('InputFile')
csv_file = pd.read_excel(excelFile, header=None, engine='xlrd').replace(pd.np.nan,None).values.tolist()

The problem is that I observe unicode characters in some str and I don’t know how to remove them.
I find for example ‘BE\xa0BELGIUM\xa0BE\xa0BELGIUM\xa0MDPB\xa04201’

Do you think I have the right import method and do you have any ideas to solve this problem?

Thank you in advance

Maybe you can change the enctype to enctype=multipart/form-data; charset=utf-8

Thanks for your answer,
Sorry but it seams that the syntax is not correct. Nothing append when i import my file.

I found something like this

<form method="post" enctype="multipart/form-data" accept-charset="utf-8">{% csrf_token %}

but it doesn’t work either. I still have the unicode characters in some strings.

Since you’re using Panda to read the file and not one of the standard libraries, this is probably something you would need to configure through it.

I don’t see where Django is going to have anything to do with this process.