s3fs并将CSV直接上传到S3存储桶

时间:2019-08-14 09:02:27

标签: python amazon-web-services amazon-s3

我目前正在尝试直接在AWS S3上上传CSV文件。在与AWS的连接正常工作的同时,我仍然很难将.CSV保存在缓冲区之外。如何解决最后一步?

    buff = io.StringIO()
    writer = csv.writer(buff, dialect='excel', delimiter=',')
    writer.writerow(["a", "b", "c"])
    buff2 = io.BytesIO(buff.getvalue().encode())

    s3 = s3fs.S3FileSystem(
        anon=False,
        key=settings.ML_AWS_ACCESS_KEY_ID,
        secret=settings.ML_AWS_SECRET_ACCESS_KEY,
    )

    BUCKET_NAME = 'fbprophet'
    with s3.open(BUCKET_NAME + "/test.csv", "w") as f:
        # What should I write in here?

0 个答案:

没有答案