andreale
02/26/2024, 10:10 AMXuanwo
02/26/2024, 10:11 AMXuanwo
02/26/2024, 10:12 AMXuanwo
02/26/2024, 10:14 AMXuanwo
02/26/2024, 10:17 AMandreale
02/26/2024, 10:18 AMimport opendal
op = opendal.Operator("s3", root="/tmp", bucket="your_bucket_name", region="your_region")
op.write("test.txt", b"Hello World")
print(op.read("test.txt"))
print(op.stat("test.txt").content_length)andreale
02/26/2024, 10:19 AMtest.txt from s3 using op.read("test.txt"), so how do I consume this op.read("test.txt") to pandas/polars, prefering polars?Xuanwo
02/26/2024, 10:20 AMXuanwo
02/26/2024, 10:21 AMop.read() is Bytes, you can pass it to polars's read_xxx API like polars.read_json(bs)andreale
02/26/2024, 10:22 AMXuanwo
02/26/2024, 10:22 AMpolars.read_json() also accept file like object, so you can also do polars.read_json(op.open(path))andreale
02/26/2024, 10:26 AMXuanwo
02/26/2024, 10:27 AMXuanwo
02/26/2024, 10:27 AMandreale
02/26/2024, 10:28 AMandreale
02/26/2024, 10:29 AMXuanwo
02/26/2024, 10:29 AMandreale
02/26/2024, 10:30 AMXuanwo
02/26/2024, 10:30 AMandreale
02/26/2024, 10:31 AMandreale
02/26/2024, 10:31 AMandreale
02/26/2024, 10:34 AMandreale
02/26/2024, 10:34 AMXuanwo
02/26/2024, 10:34 AMXuanwo
02/26/2024, 10:35 AMandreale
02/26/2024, 10:35 AMandreale
02/26/2024, 10:35 AMXuanwo
02/26/2024, 10:35 AMandreale
02/26/2024, 10:37 AMXuanwo
02/26/2024, 10:37 AMandreale
02/26/2024, 10:38 AMandreale
02/26/2024, 10:39 AMXuanwo
02/26/2024, 10:40 AMXuanwo
02/26/2024, 10:40 AMXuanwo
02/26/2024, 10:40 AMbeldathas
02/26/2024, 10:42 AMreadable which returns True to make it play nicely with Python's io.IOBaseXuanwo
02/26/2024, 10:43 AMbeldathas
02/26/2024, 10:44 AMXuanwo
02/26/2024, 10:44 AMbeldathas
02/26/2024, 10:48 AMandreale
02/26/2024, 2:44 PMandreale
02/26/2024, 2:44 PMandreale
02/26/2024, 2:45 PMpython
def ingest_log():
dotenv.load_dotenv()
access_key_id = os.getenv("AWS_ACCESS_KEY_ID")
secret_access_key = os.getenv("AWS_SECRET_ACCESS_KEY")
region = os.getenv("AWS_REGION")
op = opendal.Operator(
"s3",
root='/log_content/',
bucket='data',
region=region,
endpoint='http://127.0.0.1:9000',
access_key_id=access_key_id,
secret_access_key=secret_access_key,
)
bs = op.read(["20220401.json", "20220402.json"]) #this fails
return bsXuanwo
02/26/2024, 3:34 PMXuanwo
02/26/2024, 3:35 PMpython
bs = op.read(["20220401.json", "20220402.json"])
is strange.Xuanwo
02/26/2024, 3:35 PMbs.andreale
02/26/2024, 3:41 PMop.read should support read a list of str of list of path or glob patternsandreale
02/26/2024, 3:43 PMbs, I have to get it to bytes, i.e. bs.tobytesXuanwo
02/26/2024, 4:42 PMXuanwo
02/26/2024, 4:42 PMandreale
02/26/2024, 4:45 PMandreale
02/26/2024, 6:48 PMXuanwo
02/27/2024, 1:38 AMlist to fetch a list of file paths, and use read to get conten the file, and than fed into polars.Xuanwo
02/27/2024, 1:38 AMscan_xxx works with opendal.andreale
02/27/2024, 2:08 AMbeldathas
03/14/2024, 8:26 PMXuanwo
03/15/2024, 1:53 AM