2022-12-01
python-timestamp

Read More

2022-05-09
boto3-client-resource

了解一下 boto3 中 client & resource 的差異

Reference

Read More

2022-05-09
python-multiple-json-oobject

在一個檔案中,儲存了多個 json objects,用一般的 json.loads 會出現 error,需要找方式自行 parse 為 object

Sample code

`
from json import JSONDecoder, JSONDecodeError
import re

NOT_WHITESPACE = re.compile(r’[^\s]’)

def decode_stacked(document, pos=0, decoder=JSONDecoder()):
while True:
match = NOT_WHITESPACE.search(document, pos)
if not match:
return
pos = match.start()

try:
    obj, pos = decoder.raw_decode(document, pos)
except JSONDecodeError:
    # do something sensible if there's some error
    raise
yield obj

s = “””

{“a”: 1}
[
1
,
2
]

“””

for obj in decode_stacked(s):
print(obj)
`

Reference

Read More

2022-05-09
python-read-gzip-s3

要用 python 讀取儲存在 S3 中的 gzip 檔案資料
使用的過程中,boto3 有用 s3_client 也有用 s3 resource 取得 S3 object 的方式,需要找時間再研究這兩者的差異

code sample

def load_gzip(client, bucket, key): response = client.get_object(Bucket=bucket, Key=key) content = response['Body'].read() with gzip.GzipFile(fileobj=io.BytesIO(content), mode='rb') as fh: file_content = fh.read() return file_content.decode("utf-8")

讀多個 S3 檔案的方式

Reference

Read More

2022-04-06
python-argparse

Read More

2022-03-30
my-python-project

用這份文件,簡略記錄一下自己要捉取甲骨文資料,用到的一些 package & 參考文件

有關 word reference

有關 google drive api

有關 selenium reference

selenium youtube 介紹

Read More

2021-12-09
python-oop

Read More

2021-12-09
python-factory-pattern

在針對不同的 telemetry-type 實作不同的 de-normalize & to_parquet 時,覺得這滿適合用 Factory Pattern 的,就花些時間來試試看囉
這樣做,覺得滿好的

Reference

同場加映

Read More

2021-12-08
python-log-function

在 debug python 的時候,總想知道有沒有 call 到某個 function,目前是有用 decorator 來用
進階的方式為使用 dataclass,這還要找時間來試試囉

Reference

Read More

2021-12-08
python-dataclass

最近在使用 class & decorators 時,都有看到 dataclasses 的說明,就來用用看囉
滿有趣的

Reference

Read More