소스 검색

Upload files to '.'

SadhulaSaiKumar 1 년 전
부모
커밋
0108f55089
1개의 변경된 파일117개의 추가작업 그리고 0개의 파일을 삭제
  1. 117
    0
      Data Processing Guide.ipynb

+ 117
- 0
Data Processing Guide.ipynb 파일 보기

@@ -0,0 +1,117 @@
1
+{
2
+ "cells": [
3
+  {
4
+   "cell_type": "code",
5
+   "execution_count": null,
6
+   "id": "193481de",
7
+   "metadata": {},
8
+   "outputs": [],
9
+   "source": [
10
+    "# A sample of input data can be generate from below code for invoice,resume,Businesscard,Attendence."
11
+   ]
12
+  },
13
+  {
14
+   "cell_type": "code",
15
+   "execution_count": null,
16
+   "id": "04dbb099",
17
+   "metadata": {},
18
+   "outputs": [],
19
+   "source": [
20
+    "import base64\n",
21
+    "import json\n",
22
+    "empty=[]\n",
23
+    "\n",
24
+    "found=\"file_path\"\n",
25
+    "name = found\n",
26
+    "image = open(name, 'rb')\n",
27
+    "image_read = image.read()\n",
28
+    "image_64_encode = base64.b64encode(image_read)\n",
29
+    "NULL = 'null'\n",
30
+    "empty.append(\"ByteData--\" + (NULL).strip('\"\"'))\n",
31
+    "image_64_encode = image_64_encode.decode('utf-8')\n",
32
+    "empty.append(\"FileData--\" + str(image_64_encode))\n",
33
+    "imagedata = name.split(\"\\\\\")\n",
34
+    "imagename = str(imagedata[-1]).replace('\"', '').replace(\"[\", \"\").replace(\"]\", \"\")\n",
35
+    "imagename1 = str(imagename).split('.')\n",
36
+    "\n",
37
+    "imagename = str(imagename1[-2]).replace(\"[\", \"]\")\n",
38
+    "empty.append(\"FileName--\" + imagename)\n",
39
+    "empty.append(\"FilePath--\" + found)\n",
40
+    "imageExtension = str(imagename1[-1]).replace(\"[\", \"]\")\n",
41
+    "empty.append(\"FileType--\" + imageExtension)\n",
42
+    "\n",
43
+    "import pandas as pd\n",
44
+    "df = pd.DataFrame(empty)\n",
45
+    "df = df[0].str.split(\"--\", expand=True)\n",
46
+    "data1 = pd.DataFrame(df[0])\n",
47
+    "data2 = pd.DataFrame(df[1])\n",
48
+    "dt = data2.set_index(data1[0])\n",
49
+    "\n",
50
+    "dt4 = dt.T\n",
51
+    "  \n",
52
+    "dictionary = dt4.to_dict(orient=\"index\")\n",
53
+    "dictionary[1]\n",
54
+    "payload1 = json.dumps(dictionary[1])"
55
+   ]
56
+  },
57
+  {
58
+   "cell_type": "code",
59
+   "execution_count": null,
60
+   "id": "ea47e4ad",
61
+   "metadata": {},
62
+   "outputs": [],
63
+   "source": [
64
+    "print(payload1)"
65
+   ]
66
+  },
67
+  {
68
+   "cell_type": "markdown",
69
+   "id": "71949236",
70
+   "metadata": {},
71
+   "source": [
72
+    "# Note\n"
73
+   ]
74
+  },
75
+  {
76
+   "cell_type": "code",
77
+   "execution_count": 2,
78
+   "id": "96574e90",
79
+   "metadata": {},
80
+   "outputs": [],
81
+   "source": [
82
+    "# when we have to test code using postman\n",
83
+    "# after give url in body select json option then \n",
84
+    "# add [] to the text generated from payload1 paste in the body and click send button "
85
+   ]
86
+  },
87
+  {
88
+   "cell_type": "code",
89
+   "execution_count": null,
90
+   "id": "f876ca7c",
91
+   "metadata": {},
92
+   "outputs": [],
93
+   "source": []
94
+  }
95
+ ],
96
+ "metadata": {
97
+  "kernelspec": {
98
+   "display_name": "Python 3 (ipykernel)",
99
+   "language": "python",
100
+   "name": "python3"
101
+  },
102
+  "language_info": {
103
+   "codemirror_mode": {
104
+    "name": "ipython",
105
+    "version": 3
106
+   },
107
+   "file_extension": ".py",
108
+   "mimetype": "text/x-python",
109
+   "name": "python",
110
+   "nbconvert_exporter": "python",
111
+   "pygments_lexer": "ipython3",
112
+   "version": "3.11.5"
113
+  }
114
+ },
115
+ "nbformat": 4,
116
+ "nbformat_minor": 5
117
+}

Loading…
취소
저장