Переглянути джерело

변수 초기화 문제로 데이터 중첩 문제 수정

heewon 3 роки тому
батько
коміт
31f9ff3730

+ 24 - 24
ambt-wallpad-site-transform/ambt-wallpad-site-transform.ipynb

@@ -2,8 +2,8 @@
  "cells": [
   {
    "cell_type": "code",
-   "execution_count": 13,
-   "id": "d8aaf170",
+   "execution_count": 22,
+   "id": "873b343d",
    "metadata": {},
    "outputs": [],
    "source": [
@@ -15,8 +15,8 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 14,
-   "id": "17335ed0",
+   "execution_count": 23,
+   "id": "d78c4890",
    "metadata": {},
    "outputs": [],
    "source": [
@@ -26,8 +26,8 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 15,
-   "id": "199da9f2",
+   "execution_count": 24,
+   "id": "fed62c89",
    "metadata": {},
    "outputs": [],
    "source": [
@@ -36,8 +36,8 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 16,
-   "id": "07eab849",
+   "execution_count": 25,
+   "id": "408876b3",
    "metadata": {},
    "outputs": [],
    "source": [
@@ -46,24 +46,15 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 17,
-   "id": "752bff31",
+   "execution_count": 26,
+   "id": "5bb79584",
    "metadata": {},
    "outputs": [],
    "source": [
-    "jsondata = {}\n",
-    "for i in site :\n",
-    "    jsondata[site[i]] = \"\""
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 18,
-   "id": "1eafb250",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "for object in bucket.objects.filter(Prefix='dev/year=2021'):\n",
+    "for object in bucket.objects.filter(Prefix='type=test/'):\n",
+    "    jsondata = {}\n",
+    "    for i in site :\n",
+    "        jsondata[site[i]] = \"\"\n",
     "    key = object.key\n",
     "    if not key.endswith('/'):\n",
     "        object = s3.Object(s3BucketName,key)\n",
@@ -81,11 +72,20 @@
     "                jsondata[site[jsonpayload['site']]] += json.dumps(jsonpayload) + '\\n'                \n",
     "            for i in site:\n",
     "                if len(jsondata[site[i]]) != 0:\n",
-    "                    object = s3.Object('hdci-ambt-wallpad-raw','test3/{}/year={}/month={}/day={}/ambt-preden-lambda-consumer-dev-{}-{}-{}-{}-{}-{}-{}'.format(i, str(year), str(month), str(day), str(year), str(month), str(day), str(hour), str(minute), str(second), str(uuid.uuid4())))                    \n",
+    "                    object = s3.Object('hdci-ambt-wallpad-raw','test2/{}/year={}/month={}/day={}/ambt-preden-lambda-consumer-dev-{}-{}-{}-{}-{}-{}-{}'.format(i, str(year), str(month), str(day), str(year), str(month), str(day), str(hour), str(minute), str(second), str(uuid.uuid4())))                    \n",
     "                    object.put(Body=jsondata.get(site[i]))\n",
+    "            #s3.Object(s3BucketName,key).delete()\n",
     "        except ValueError as e:\n",
     "            print (e)"
    ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "bb6d121f",
+   "metadata": {},
+   "outputs": [],
+   "source": []
   }
  ],
  "metadata": {