Upload files to '.'
This commit is contained in:
@@ -0,0 +1,117 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "193481de",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# A sample of input data can be generate from below code for invoice,resume,Businesscard,Attendence."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "04dbb099",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import base64\n",
|
||||||
|
"import json\n",
|
||||||
|
"empty=[]\n",
|
||||||
|
"\n",
|
||||||
|
"found=\"file_path\"\n",
|
||||||
|
"name = found\n",
|
||||||
|
"image = open(name, 'rb')\n",
|
||||||
|
"image_read = image.read()\n",
|
||||||
|
"image_64_encode = base64.b64encode(image_read)\n",
|
||||||
|
"NULL = 'null'\n",
|
||||||
|
"empty.append(\"ByteData--\" + (NULL).strip('\"\"'))\n",
|
||||||
|
"image_64_encode = image_64_encode.decode('utf-8')\n",
|
||||||
|
"empty.append(\"FileData--\" + str(image_64_encode))\n",
|
||||||
|
"imagedata = name.split(\"\\\\\")\n",
|
||||||
|
"imagename = str(imagedata[-1]).replace('\"', '').replace(\"[\", \"\").replace(\"]\", \"\")\n",
|
||||||
|
"imagename1 = str(imagename).split('.')\n",
|
||||||
|
"\n",
|
||||||
|
"imagename = str(imagename1[-2]).replace(\"[\", \"]\")\n",
|
||||||
|
"empty.append(\"FileName--\" + imagename)\n",
|
||||||
|
"empty.append(\"FilePath--\" + found)\n",
|
||||||
|
"imageExtension = str(imagename1[-1]).replace(\"[\", \"]\")\n",
|
||||||
|
"empty.append(\"FileType--\" + imageExtension)\n",
|
||||||
|
"\n",
|
||||||
|
"import pandas as pd\n",
|
||||||
|
"df = pd.DataFrame(empty)\n",
|
||||||
|
"df = df[0].str.split(\"--\", expand=True)\n",
|
||||||
|
"data1 = pd.DataFrame(df[0])\n",
|
||||||
|
"data2 = pd.DataFrame(df[1])\n",
|
||||||
|
"dt = data2.set_index(data1[0])\n",
|
||||||
|
"\n",
|
||||||
|
"dt4 = dt.T\n",
|
||||||
|
" \n",
|
||||||
|
"dictionary = dt4.to_dict(orient=\"index\")\n",
|
||||||
|
"dictionary[1]\n",
|
||||||
|
"payload1 = json.dumps(dictionary[1])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "ea47e4ad",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"print(payload1)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "71949236",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# Note\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"id": "96574e90",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# when we have to test code using postman\n",
|
||||||
|
"# after give url in body select json option then \n",
|
||||||
|
"# add [] to the text generated from payload1 paste in the body and click send button "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "f876ca7c",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.11.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user