Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can´t read csv files from S3 #646

Closed
jplicona opened this issue Jul 4, 2023 · 1 comment
Closed

Can´t read csv files from S3 #646

jplicona opened this issue Jul 4, 2023 · 1 comment

Comments

@jplicona
Copy link

jplicona commented Jul 4, 2023

Hi, I want to read csv and parquet files from S3 AWS in my local machine using VSCode. However, I am not quite sure how to do it. I have been trying to find something on the documentation, but it hasnt been helpful.

using AWS.AWSServices: s3
s3("GET", "s3://test1/test_file.csv")

#GET THE FOLLOWING ERROR:
ERROR: Can't find AWS credentials!

How can i specify the credentials (aws_access_key_id, aws_secret_access_key)? What is the right way to write the julia script?
In python I was able to connect to S3 by using boto3 and awswrangler:

import awswrangler as wr
import boto3

# Configure AWS credentials
session = boto3.Session(
    aws_access_key_id="123456789",
    aws_secret_access_key="asdfghjklqwertyuiozxcvbnm"
)

import awswrangler as wr

df = wr.s3.read_csv(
    path="s3://test1/test_file.csv",
    boto3_session=session
)

print(df)

Help. Thanks in advance

@ararslan
Copy link
Member

ararslan commented Jul 3, 2024

In case this is still relevant for you nearly one year to the day from when you posted it...

There are a few ways you could go about this. The workflow I typically use is with AWSS3.jl and its S3Path type, which can be passed directly to CSV.read. The only use of AWS.jl in this case is for credential management.

using AWS, AWSS3, CSV, DataFrames

# If you don't have a profile defined in `~/.aws/config`:
config = AWSConfig(AWSCredentials("123456789", "asdfghjklqwertyuiozxcvbnm"))
# Or if you do have a profile, you can use it by name:
config = AWSConfig(; profile="whatever")

df = CSV.read(S3Path("s3://test1/test_file.csv"; config), DataFrame)

@ararslan ararslan closed this as completed Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants