Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 无法将csv扩展名为的文件从pandas写入AWS S3_Python 3.x_Pandas_Amazon Web Services - Fatal编程技术网

Python 3.x 无法将csv扩展名为的文件从pandas写入AWS S3

Python 3.x 无法将csv扩展名为的文件从pandas写入AWS S3,python-3.x,pandas,amazon-web-services,Python 3.x,Pandas,Amazon Web Services,我正在尝试从dataframe编写一个文件AmazonS3 我无法在S3中获取csv格式的文件 我的代码 import s3fs bytes_to_write = data_upload.to_csv(index=False).encode() fs = s3fs.S3FileSystem(key='secret_key',secret='secret_secret') with fs.open('cotydata/datadump'+'_'+(date.today()).strftime("%

我正在尝试从dataframe编写一个文件AmazonS3

我无法在S3中获取csv格式的文件

我的代码

import s3fs
bytes_to_write = data_upload.to_csv(index=False).encode()
fs = s3fs.S3FileSystem(key='secret_key',secret='secret_secret')
with fs.open('cotydata/datadump'+'_'+(date.today()).strftime("%Y%m%d").csv, 'wb') as f:
    f.write(bytes_to_write)
我的预期产出

数据转储_20190401.csv 数据转储_20190402.csv


如何做到这一点

必须正确引用文件名的所有部分。此外,还需要正确使用datetime:

import s3fs
bytes_to_write = data_upload.to_csv(index=False).encode()
fs = s3fs.S3FileSystem(key='secret_key',secret='secret_secret')
with fs.open('cotydata/datadump_'+datetime.datetime.now().strftime("%Y%m%d")+'.csv', 'wb') as f:
    f.write(bytes_to_write)