|
@@ -0,0 +1,49 @@
|
|
1
|
+# A sample of input data can be generate from below code for invoice,resume,Businesscard,Attendence.
|
|
2
|
+
|
|
3
|
+import base64
|
|
4
|
+import json
|
|
5
|
+empty=[]
|
|
6
|
+
|
|
7
|
+found="file_path"
|
|
8
|
+name = found
|
|
9
|
+image = open(name, 'rb')
|
|
10
|
+image_read = image.read()
|
|
11
|
+image_64_encode = base64.b64encode(image_read)
|
|
12
|
+NULL = 'null'
|
|
13
|
+empty.append("ByteData--" + (NULL).strip('""'))
|
|
14
|
+image_64_encode = image_64_encode.decode('utf-8')
|
|
15
|
+empty.append("FileData--" + str(image_64_encode))
|
|
16
|
+imagedata = name.split("\\")
|
|
17
|
+imagename = str(imagedata[-1]).replace('"', '').replace("[", "").replace("]", "")
|
|
18
|
+imagename1 = str(imagename).split('.')
|
|
19
|
+
|
|
20
|
+imagename = str(imagename1[-2]).replace("[", "]")
|
|
21
|
+empty.append("FileName--" + imagename)
|
|
22
|
+empty.append("FilePath--" + found)
|
|
23
|
+imageExtension = str(imagename1[-1]).replace("[", "]")
|
|
24
|
+empty.append("FileType--" + imageExtension)
|
|
25
|
+
|
|
26
|
+import pandas as pd
|
|
27
|
+df = pd.DataFrame(empty)
|
|
28
|
+df = df[0].str.split("--", expand=True)
|
|
29
|
+data1 = pd.DataFrame(df[0])
|
|
30
|
+data2 = pd.DataFrame(df[1])
|
|
31
|
+dt = data2.set_index(data1[0])
|
|
32
|
+
|
|
33
|
+dt4 = dt.T
|
|
34
|
+
|
|
35
|
+dictionary = dt4.to_dict(orient="index")
|
|
36
|
+dictionary[1]
|
|
37
|
+payload1 = json.dumps(dictionary[1])
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+print(payload1)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+#Note
|
|
45
|
+#when we have to test code using postman
|
|
46
|
+#after give url in body select json option then
|
|
47
|
+#add [] to the text generated from payload1 paste in the body and click send button
|
|
48
|
+
|
|
49
|
+
|