Reputation: 2446
The following loads an empty file to my s3 bucket. Why?
df = pd.DataFrame([[1,2,3],[324,34,25], [463,23,43]])
out = df.to_csv(index=False) # unicode string (i'm in python 3)
s3 = boto3.resource('s3')
BUCKET = "MyBucketThatDefExistsAndIHaveAccessTo"
bucket = s3.Bucket(BUCKET)
obj = bucket.Object('TEST1')
obj.put(df.to_csv(index=False)) # loads an empty file "TEST1" to my bucket.
# I've also tried, but same result.
obj.put(bytes(df.to_csv(index=False), 'utf8'))
Upvotes: 1
Views: 1813
Reputation: 2446
I'm just dumb. Needs the Body=
kwarg.
obj.put(Body=df.to_csv(index=False)
works
Upvotes: 0
Reputation: 13055
Should it not be,
obj.put(Body=df.to_csv(index=False)) # loads an empty file "TEST1" to my bucket.
Missing Body named parameter. Since first parameter is ACL, you need to specify the name.
Hope it helps.
Upvotes: 2