Reputation: 31
I used to use the pandas command: pd.read_csv('path copied from studio lab') to read the csv file but now this same command seems to not work anymore. The path that I used in the pandas command I got by right-clicking on the upload filed and then selecting copy path.
Any help?
The error message:
FileNotFoundError: [Errno 2] No such file or directory: 'Titanic/train.csv'
Upvotes: 3
Views: 920
Reputation: 5193
You may need to add ~/
in front of the file path
df = pd.read_csv("~/data/sagemaker_sample.csv")
instead of
df = pd.read_csv("data/sagemaker_sample.csv")
Upvotes: 0
Reputation: 11
You can use boto3 to read the files
#pip install boto3
import boto3
s3 = boto3.client('s3')
obj = s3.get_object(
Bucket = 'bucket_name',
Key = 'path/to/file.csv'
)
df = pd.read_csv(obj['Body'], nrows=100)
check few samples using nrows
to make sure you see the data you were expecting.
Upvotes: 0