<jupyter_start><jupyter_text>Amazon S3 Experiments Before we get started make sure you configure the AWS cli from https://aws.amazon.com/cli/   First let's show that we can copy a test file to our bucket<jupyter_code>import os
import boto3
s3 = boto3.resource('s3')
data = open('test.txt','rb')
s3.Bucket('jpf-python-datastore').put_object(Key='text.txt', Body=data)<jupyter_output><empty_output><jupyter_text>Now lets show that we can write directly to a file<jupyter_code>import boto3
data_string="Now is the time for all good men to come to the aid of their party."
s3 = boto3.resource('s3')
#obj = s3.Object('jpf-python-datastore', 'test.txt')
#obj.put(Body=data_string)
s3.Bucket('jpf-python-datastore').put_object(Key='text1.txt', Body=data_string)<jupyter_output><empty_output><jupyter_text>Now lets save a dataframe<jupyter_code>import boto3
import pandas as pd
# setup a dataframe with some data
columns=['index','First Name','Last Name','Gender','Dojo','Age','Rank','Feet','Inches','Height','Weight','BMI','Events','Weapons']
data=[(255,'Lucas','LeMay','Male','Parker',10,'Yellow',4,3,'4 ft. 3 in.',52,154,'2 Events - Forms & Sparring ($75)','None'),
      (194,'Jakie','Coleman','Male','Cheyenne',10,'Yellow',4,0,'4',60,156,'2 Events - Forms & Sparring ($75)','Weapons ($35)'),
      (195,'Katie','Coleman','Female','Cheyenne',12,'Yellow',4,0,'4',65,161,'2 Events - Forms & Sparring ($75)','Weapons ($35)')]
df=pd.DataFrame(data,columns=columns)
df
s3 = boto3.resource('s3')
data_string = df.to_csv()
data_string
s3.Bucket('jpf-python-datastore').put_object(Key='text.csv', Body=data_string)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1881127450980392, 'fraction_numerical': 0.04350490196078431, 'mean_word_length': 7.827027027027027, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '254924', 'license': 'MIT', 'n_tokens_mistral': 642, 'n_tokens_neox': 591, 'n_words': 120, 'path': 'S3_experiments.ipynb', 'repo_name': 'JohnFunkCode/S3_experiments', 'size': '1632'}