python - Unable to save unicode file properly with utf-8 encoding from HTTP response -
i have storage web service manage download file , upload file wrote in scala play framework. in django web service, dealing pandas , therefore have function parse csv pandas save them pickle format.
after uploaded pickle file storage web service, opened file in atom in storage web service , pickle file fine (i save pkl in local comparison). screenshot below.
however, when tried download down storage web service local, weird thing happened. of symbol changed. screenshot below.
the response header send me file contains content type is
'content-type': 'application/octet-stream'
to save file in django python, tried with
with codecs.open(filepath + localfilename, 'w','utf-8') localfile: localfile.write(res.text)
this cause trouble when use local file parse pickle dataframe.
df = pandas.read_pickle(localfilepath)
when tries decode it, logs
unicodedecodeerror @ /dataproc/filter_column 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
since send requests around in postman, provides me message.
unicode error hint string not encoded/decoded was: �
Comments
Post a Comment