Answer the question
In order to leave comments, you need to log in
How to solve encoding problem?
Help with coding. There is some functionality, namely: from the client side, an .xls file comes through AJAX. There, using the function, pyexcel.get_array()
an array is obtained and sent back to the client as a file. Here is the code:
import pyexcel as pe
file_exist = request.FILES.get('upload_excel_file', None)
records_array = pe.get_array(file_type='xls', file_content=file_exist.read(), start_row=8)
response = HttpResponse(records_array)
response['Content-Type'] = 'text/plain'
response['Content-Disposition'] = 'attachment; filename=response-text.txt'
return response
[u'\u0421\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439 \u043a\u0440\u0430\u0431', '', '', 2195, '', 27216.15][u'\u0414\u044e\u0431\u0435\u043b\u044c-\u0433\u0432\u043e\u0437\u0434\u044c \u0433\u0440\u0438\u0431 "\u0423\u043a\u0440\u0430\u0438\u043d\u0430" 6\u044540(200\u0448\u0442)', '', '', 2000, '', 3560]
.encode('utf-8')
['\xd0\xa1\xd0\xbe\xd0\xb5\xd0\xb4\xd0\xb8\xd0\xbd\xd0\xb8\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c \xd0\xbf\xd1\x80\xd0\xbe\xd1\x84\xd0\xb8\xd0\xbb\xd0\xb5\xd0\xb9 \xd0\xba\xd1\x80\xd0\xb0\xd0\xb1', '', '',
\u041a\u0430\u0431\u0435\u043b\u044c (\u043f\u0440\u043e\u0432\u043e\u0434) FTP 4 Cat 5e 24 AWG Cu (SUPRLAN)'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question