我希望使用boto3甚至类似Python中的smart_open从S3中逐行读取一个文件,然后处理每一行(例如清除某些字段),然后将这些行写回S3。关键是不要在内存中保存任何数据。有什么建议吗?我试过使用下面的方法,但没有成功
into = "s3://"+access_key+":"+secret_key+"@"+bucket+"/Filetoread.csv"
out = "s3://"+access_key+":"+secret_key+"@"+bucket+"/Filetowrite.csv"
def streamline(inputfile, outputfile):
with smart_open.smart_open(inputfile, 'r') as infile, smart_open.smart_open(outputfile, 'w') as outfile:
for line in infile:
outfile.write(line + '\n')
streamline(into, out)
目前没有回答
相关问题 更多 >
编程相关推荐