Python で始める AWS Boto 入門
Maksim Pecherskiy
Data engineer
df = pd.read_csv('https://gid-staging.potholes.csv')

許可あり
# Generate the boto3 client for interacting with S3 s3 = boto3.client('s3', region_name='us-east-1', aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET)# Use client to download a file s3.download_file( Filename='potholes.csv', Bucket='gid-requests', Key='potholes.csv')









ファイルをアップロード
s3.upload_file(
Filename='potholes.csv', Bucket='gid-requests', Key='potholes.csv')
ACL を 'public-read' に設定
s3.put_object_acl(
Bucket='gid-requests', Key='potholes.csv', ACL='public-read')
'public-read' ACL でアップロード
s3.upload_file(
Bucket='gid-requests',
Filename='potholes.csv',
Key='potholes.csv',
ExtraArgs={'ACL':'public-read'})
S3オブジェクトURLの書式
https://{bucket}.{key}
Key='2019/potholes.csv' のURL
https://gid-requests.2019/potholes.csv
オブジェクトURL文字列を生成
url = "https://{}.{}".format(
"gid-requests",
"2019/potholes.csv")
'https://gid-requests.2019/potholes.csv'
# URL を Pandas に読み込む
df = pd.read_csv(url)






ACL を 'public-read' に設定
s3.put_object_acl(
Bucket='gid-requests', Key='potholes.csv', ACL='public-read')
ACL を 'private' に設定
s3.put_object_acl(
Bucket='gid-requests', Key='potholes.csv', ACL='private')
'public-read' ACL でアップロード
s3.upload_file(
Bucket='gid-requests',
Filename='potholes.csv',
Key='potholes2.csv',
ExtraArgs={'ACL':'public-read'})
オブジェクトURL文字列を生成
url = "https://{}.{}".format(
"gid-requests",
"2019/potholes.csv")
'https://gid-requests.2019/potholes.csv'
# URL を Pandas に読み込む
df = pd.read_csv(url)
Python で始める AWS Boto 入門