Guest User

Untitled

a guest
Jan 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. `[(deliveryObject){
  2. id = "0bf003ee0000000000000000000002a11cb6"
  3. start = 2019-01-02 09:30:00
  4. messageId = "68027b94b892396ed29581cde9ad07ff"
  5. status = "sent"
  6. type = "normal"
  7. }, (deliveryObject){
  8. id = "0bf0BE3ABFFDF8744952893782139E82793B"
  9. start = 2018-12-29 23:00:00
  10. messageId = "0bc403eb0000000000000000000000113404"
  11. status = "sent"
  12. type = "transactional"
  13. }, (deliveryObject){
  14. id = "0bf0702D03CB42D848CBB0B0AF023A87FA65"
  15. start = 2018-12-29 23:00:00
  16. messageId = "0bc403eb0000000000000000000000113403"
  17. status = "sent"
  18. type = "transactional"
  19. }
  20. ]`
  21.  
  22. from suds.client import Client
  23.  
  24. list_of_deliveryObjects = [(deliveryObject){
  25. id = "0bf003ee0000000000000000000002a11cb6"
  26. start = 2019-01-02 09:30:00
  27. messageId = "68027b94b892396ed29581cde9ad07ff"
  28. status = "sent"
  29. type = "normal"
  30. }, (deliveryObject){
  31. id = "0bf0BE3ABFFDF8744952893782139E82793B"
  32. start = 2018-12-29 23:00:00
  33. messageId = "0bc403eb0000000000000000000000113404"
  34. status = "sent"
  35. type = "transactional"
  36. }, (deliveryObject){
  37. id = "0bf0702D03CB42D848CBB0B0AF023A87FA65"
  38. start = 2018-12-29 23:00:00
  39. messageId = "0bc403eb0000000000000000000000113403"
  40. status = "sent"
  41. type = "transactional"
  42. }
  43. ]
  44.  
  45.  
  46. data = [Client.dict(suds_object) for suds_object in list_of_deliveryObjects]
  47. df = pd.DataFrame(data)
  48.  
  49. import re
  50. import pandas as pd
  51.  
  52. x = """[(deliveryObject){
  53. id = "0bf003ee0000000000000000000002a11cb6"
  54. start = 2019-01-02 09:30:00
  55. messageId = "68027b94b892396ed29581cde9ad07ff"
  56. status = "sent"
  57. type = "normal"
  58. }, (deliveryObject){
  59. id = "0bf0BE3ABFFDF8744952893782139E82793B"
  60. start = 2018-12-29 23:00:00
  61. messageId = "0bc403eb0000000000000000000000113404"
  62. status = "sent"
  63. type = "transactional"
  64. }, (deliveryObject){
  65. id = "0bf0702D03CB42D848CBB0B0AF023A87FA65"
  66. start = 2018-12-29 23:00:00
  67. messageId = "0bc403eb0000000000000000000000113403"
  68. status = "sent"
  69. type = "transactional"
  70. }
  71. ]"""
  72.  
  73. a = re.sub(' =', ':', x)
  74. a = re.sub('(deliveryObject)', '', a)
  75.  
  76. for x in ['id', 'start', 'messageId', 'status', 'type']:
  77. a = re.sub(x, '''+x+''', a)
  78.  
  79. a = re.sub("(?<=["0])n(?= +?['])", 'n,', a)
  80. a = re.sub('(?<=[0])n(?=,)', '"n', a)
  81. a = re.sub('(?<=[:]) (?=[0-9])', ' "', a)
  82. a = re.sub('(?<= )"(?=[w])', '["', a)
  83. a = re.sub('(?<=[w])"(?=n)', '"]', a)
  84.  
  85. list_of_dict = eval(a)
  86. df = pd.DataFrame(list_of_dict[0])
  87. print(df.head())
  88.  
  89. id start messageId status type
  90. 0 0bf003ee0000000000000000000002a11cb6 2019-01-02 09:30:00 68027b94b892396ed29581cde9ad07ff sent normal
  91.  
  92. import pandas as pd
  93. lst =[{
  94. 'id':"0bf003ee0000000000000000000002a11cb6",
  95. 'start' : "2019-01-02 09:30:00",
  96. 'messageId': "68027b94b892396ed29581cde9ad07ff",
  97. 'status' : "sent",
  98. 'type' : "normal"
  99. },{
  100. 'id' : "0bf0BE3ABFFDF8744952893782139E82793B",
  101. 'start' : "2018-12-29 23:00:00",
  102. 'messageId' : "0bc403eb0000000000000000000000113404",
  103. 'status' : "sent",
  104. 'type' : "transactional"
  105. }, {
  106. 'id' : "0bf0702D03CB42D848CBB0B0AF023A87FA65",
  107. 'start' : "2018-12-29 23:00:00",
  108. 'messageId' : "0bc403eb0000000000000000000000113403",
  109. 'status' : "sent",
  110. 'type' : "transactional"
  111. }]
  112. df = pd.DataFrame(lst)
  113. df
  114.  
  115. id messageId start status type
  116. 0 0bf003ee0000000000000000000002a11cb6 68027b94b892396ed29581cde9ad07ff 2019-01-02 09:30:00 sent normal
  117. 1 0bf0BE3ABFFDF8744952893782139E82793B 0bc403eb0000000000000000000000113404 2018-12-29 23:00:00 sent transactional
  118. 2 0bf0702D03CB42D848CBB0B0AF023A87FA65 0bc403eb0000000000000000000000113403 2018-12-29 23:00:00 sent transactional
Add Comment
Please, Sign In to add comment