Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Data_Processing_Guide.py 1.3KB

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