Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Now lets try to read a file from a bucket into Python's memory, so we can work with it inside Python without ever saving the file on to our local computer:

Code Block
languagepy
#Read a file into Python's memory and open it as a string
filename = '/folder1/folder2/myfile.txt'  #Fill this in  
obj = s3.get_object(Bucket=bucketname, Key=filename)
myObject = obj['Body'].read().decode('utf-8') 
print(myObject)

...