2023年5月31日水曜日

Quote

https://quotefancy.com/perseverance-quotes

“If you can’t fly then run, if you can’t run then walk, if you can’t walk then crawl, but whatever you do you have to keep moving forward.”
— Martin Luther King Jr.

“It's not that I'm so smart, it's just that I stay with problems longer.”
— Albert Einstein

このような内容も。
“A committee is a thing which takes a week to do what one good man can do in an hour.”
— Elbert Hubbard



2023年5月30日火曜日

S3 + EC2 + Python

import h5py
import s3fs
import boto3

#S3へのアクセス設定
ACCESS_KEY = "aaa"
SECRET_KEY = "bbb"
fs = s3fs.S3FileSystem(key=ACCESS_KEY, secret=SECRET_KEY)

#S3のファイル一覧取得
readPath = "s3://ccc/ddd"
files = fs.ls(readPath)

#S3のh5ファイル読み込み
h5 = h5py.File(fs.open(files [1],"rb"))
df = pd.DataFrame({"eee":np.array(h5["fff"]]["ggg"])[:,1]})

#EC2からS3へのコピー
#S3へのアクセス設定追加
AWS_REGION = "hhh"
client = boto3.client( 's3',
                      aws_access_key_id=ACCESS_KEY,
                      aws_secret_access_key=SECRET_KEY,
                      region_name=AWS_REGION )

client.upload_file("iii", "ccc", "iii")