S3文件使用路易吉当地引起了统一codeDE codeError [英] S3 file to local using luigi raises UnicodeDecodeError
本文介绍了S3文件使用路易吉当地引起了统一codeDE codeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我复制 PDF
文件到本地,使用下面这段code:
I am copying a pdf
file to local, using the following piece of code:
with self.input_target().open('r') as r:
with self.output_target().open('w') as w:
for line in r:
w.write(line)
(种)
这是基于这个问题
但是,当我执行了code,我得到了以下内容:
But when I execute that code I get the following:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 11:
invalid continuation byte
这个我试过其他的方法,没有了良好的效果:
I tried this other approach, without good results:
with self.input_target().open('r') as r, self.output_target().open('w') as w:
w.write(r.read())
什么是做这件事的正确方法是什么?
What is the correct way of doing it?
推荐答案
我最终使用 luigi.s3.S3Client
和方法 GET
,它复制一个二进制文件从/到 S3
。
I ended using luigi.s3.S3Client
and the method get
which copies a binary file from/to the s3
.
摘录:
进口路易吉
class ATask(luigi.Task):
s3_path = luigi.Parameter()
local_path = luigi.Parameter()
...
def run(self):
client = luigi.s3.S3Client()
client.get(s3_path, local_path) ## This gets the file
...
我认为,根本原因在于路易吉
使用博托
获取/把文件从/到 S3
。 (你可以在源$ C $ C见)
I think that the underlying reason is that luigi
uses boto
for getting/putting files from/to the s3
. (As you can see in the source code)
这篇关于S3文件使用路易吉当地引起了统一codeDE codeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文