如何使用dask和特定的AWS配置文件(存储在凭证文件中)读取s3上的镶木地板文件. Dask使用使用boto的s3fs.这是我尝试过的:
>>>import os
>>>import s3fs
>>>import boto3
>>>import dask.dataframe as dd
>>>os.environ['AWS_SHARED_CREDENTIALS_FILE'] = "~/.aws/credentials"
>>>fs = s3fs.S3FileSystem(anon=False,profile_name="some_user_profile")
>>>fs.exists("s3://some.bucket/data/parquet/somefile")
True
>>>df = dd.read_parquet('s3://some.bucket/data/parquet/somefile')
NoCredentialsError: Unable to locate credentials
解决方法:
没关系,这很容易,但没有在网上找到任何参考,所以这里是:
>>>import os
>>>import dask.dataframe as dd
>>>os.environ['AWS_SHARED_CREDENTIALS_FILE'] = "/path/to/credentials"
>>>df = dd.read_parquet('s3://some.bucket/data/parquet/somefile',
storage_options={"profile_name":"some_user_profile"})
>>>df.head()
# works