D
D
Dev_nab2018-10-04 00:51:51
Django
Dev_nab, 2018-10-04 00:51:51

Django - Why won't it open a file?

Error message
expected str, bytes or os.PathLike object, not InMemoryUploadedFile Error
string

data = csv.reader(open(request.FILES['file_csv']), delimiter=',')

Request information
FILES
Variable: file_csv
Value: InMemoryUploadedFile: data2_1.csv (application/vnd.ms-excel)

I seem to be doing everything according to the Django documentation.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dev_nab, 2018-10-04
@Dev_nab

I decided myself.
Specified the path to the downloaded files + file name.

data = csv.reader(open('/бла-бла/' + request.FILES['file_csv'].name + ''), delimiter=',')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question