Skip to content

Commit 52ab376

Browse files
authored
Merge pull request #9 from DRAE-MLP/csvfile
add csv to storage
2 parents 73d18c3 + c937904 commit 52ab376

File tree

1 file changed

+51
-10
lines changed

1 file changed

+51
-10
lines changed

create_dataset.ipynb

+51-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 39,
5+
"execution_count": 3,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -17,7 +17,7 @@
1717
},
1818
{
1919
"cell_type": "code",
20-
"execution_count": null,
20+
"execution_count": 4,
2121
"metadata": {},
2222
"outputs": [],
2323
"source": [
@@ -47,7 +47,7 @@
4747
},
4848
{
4949
"cell_type": "code",
50-
"execution_count": 36,
50+
"execution_count": 5,
5151
"metadata": {},
5252
"outputs": [
5353
{
@@ -139,7 +139,7 @@
139139
"0 RT @discord: ok this year's snowsgiving giveaw... None None "
140140
]
141141
},
142-
"execution_count": 36,
142+
"execution_count": 5,
143143
"metadata": {},
144144
"output_type": "execute_result"
145145
}
@@ -150,11 +150,19 @@
150150
},
151151
{
152152
"cell_type": "code",
153-
"execution_count": null,
153+
"execution_count": 6,
154+
"metadata": {},
155+
"outputs": [],
156+
"source": [
157+
"csv_file = 'prueba.csv'"
158+
]
159+
},
160+
{
161+
"cell_type": "code",
162+
"execution_count": 7,
154163
"metadata": {},
155164
"outputs": [],
156165
"source": [
157-
"csv_file = 'prueba.csv'\n",
158166
"df.to_csv(csv_file)"
159167
]
160168
},
@@ -165,19 +173,52 @@
165173
"outputs": [],
166174
"source": [
167175
"\"\"\"\n",
168-
" TODO: Add csv to S3\n",
176+
" Add csv to S3\n",
169177
"\"\"\""
170178
]
171179
},
172180
{
173181
"cell_type": "code",
174-
"execution_count": null,
182+
"execution_count": 14,
183+
"metadata": {},
184+
"outputs": [],
185+
"source": [
186+
"# Retrieve key and host from terminal\n",
187+
"aws_access_key_id = os.getenv('AWS_ACCESS_KEY_ID')\n",
188+
"aws_secret_access_key = os.getenv('AWS_SECRET_ACCESS_KEY')"
189+
]
190+
},
191+
{
192+
"cell_type": "code",
193+
"execution_count": 21,
175194
"metadata": {},
176195
"outputs": [],
177196
"source": [
178197
"import boto3\n",
179-
"s3 = boto3.resource('s3')\n",
180-
"s3.meta.client.upload_file(csv_file, 'mybucket', csv_file)"
198+
"s3 = boto3.resource('s3', region_name='us-east-1', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)"
199+
]
200+
},
201+
{
202+
"cell_type": "code",
203+
"execution_count": 26,
204+
"metadata": {},
205+
"outputs": [
206+
{
207+
"data": {
208+
"text/plain": [
209+
"s3.Object(bucket_name='tweets-hackoff1', key='prueba.csv')"
210+
]
211+
},
212+
"execution_count": 26,
213+
"metadata": {},
214+
"output_type": "execute_result"
215+
}
216+
],
217+
"source": [
218+
"# Upload a new file\n",
219+
"data = open(csv_file, 'rb')\n",
220+
"bucket = s3.Bucket('tweets-hackoff1')\n",
221+
"bucket.put_object(Key=csv_file, Body=data)"
181222
]
182223
},
183224
{

0 commit comments

Comments
 (0)