Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `[(deliveryObject){
- id = "0bf003ee0000000000000000000002a11cb6"
- start = 2019-01-02 09:30:00
- messageId = "68027b94b892396ed29581cde9ad07ff"
- status = "sent"
- type = "normal"
- }, (deliveryObject){
- id = "0bf0BE3ABFFDF8744952893782139E82793B"
- start = 2018-12-29 23:00:00
- messageId = "0bc403eb0000000000000000000000113404"
- status = "sent"
- type = "transactional"
- }, (deliveryObject){
- id = "0bf0702D03CB42D848CBB0B0AF023A87FA65"
- start = 2018-12-29 23:00:00
- messageId = "0bc403eb0000000000000000000000113403"
- status = "sent"
- type = "transactional"
- }
- ]`
- from suds.client import Client
- list_of_deliveryObjects = [(deliveryObject){
- id = "0bf003ee0000000000000000000002a11cb6"
- start = 2019-01-02 09:30:00
- messageId = "68027b94b892396ed29581cde9ad07ff"
- status = "sent"
- type = "normal"
- }, (deliveryObject){
- id = "0bf0BE3ABFFDF8744952893782139E82793B"
- start = 2018-12-29 23:00:00
- messageId = "0bc403eb0000000000000000000000113404"
- status = "sent"
- type = "transactional"
- }, (deliveryObject){
- id = "0bf0702D03CB42D848CBB0B0AF023A87FA65"
- start = 2018-12-29 23:00:00
- messageId = "0bc403eb0000000000000000000000113403"
- status = "sent"
- type = "transactional"
- }
- ]
- data = [Client.dict(suds_object) for suds_object in list_of_deliveryObjects]
- df = pd.DataFrame(data)
- import re
- import pandas as pd
- x = """[(deliveryObject){
- id = "0bf003ee0000000000000000000002a11cb6"
- start = 2019-01-02 09:30:00
- messageId = "68027b94b892396ed29581cde9ad07ff"
- status = "sent"
- type = "normal"
- }, (deliveryObject){
- id = "0bf0BE3ABFFDF8744952893782139E82793B"
- start = 2018-12-29 23:00:00
- messageId = "0bc403eb0000000000000000000000113404"
- status = "sent"
- type = "transactional"
- }, (deliveryObject){
- id = "0bf0702D03CB42D848CBB0B0AF023A87FA65"
- start = 2018-12-29 23:00:00
- messageId = "0bc403eb0000000000000000000000113403"
- status = "sent"
- type = "transactional"
- }
- ]"""
- a = re.sub(' =', ':', x)
- a = re.sub('(deliveryObject)', '', a)
- for x in ['id', 'start', 'messageId', 'status', 'type']:
- a = re.sub(x, '''+x+''', a)
- a = re.sub("(?<=["0])n(?= +?['])", 'n,', a)
- a = re.sub('(?<=[0])n(?=,)', '"n', a)
- a = re.sub('(?<=[:]) (?=[0-9])', ' "', a)
- a = re.sub('(?<= )"(?=[w])', '["', a)
- a = re.sub('(?<=[w])"(?=n)', '"]', a)
- list_of_dict = eval(a)
- df = pd.DataFrame(list_of_dict[0])
- print(df.head())
- id start messageId status type
- 0 0bf003ee0000000000000000000002a11cb6 2019-01-02 09:30:00 68027b94b892396ed29581cde9ad07ff sent normal
- import pandas as pd
- lst =[{
- 'id':"0bf003ee0000000000000000000002a11cb6",
- 'start' : "2019-01-02 09:30:00",
- 'messageId': "68027b94b892396ed29581cde9ad07ff",
- 'status' : "sent",
- 'type' : "normal"
- },{
- 'id' : "0bf0BE3ABFFDF8744952893782139E82793B",
- 'start' : "2018-12-29 23:00:00",
- 'messageId' : "0bc403eb0000000000000000000000113404",
- 'status' : "sent",
- 'type' : "transactional"
- }, {
- 'id' : "0bf0702D03CB42D848CBB0B0AF023A87FA65",
- 'start' : "2018-12-29 23:00:00",
- 'messageId' : "0bc403eb0000000000000000000000113403",
- 'status' : "sent",
- 'type' : "transactional"
- }]
- df = pd.DataFrame(lst)
- df
- id messageId start status type
- 0 0bf003ee0000000000000000000002a11cb6 68027b94b892396ed29581cde9ad07ff 2019-01-02 09:30:00 sent normal
- 1 0bf0BE3ABFFDF8744952893782139E82793B 0bc403eb0000000000000000000000113404 2018-12-29 23:00:00 sent transactional
- 2 0bf0702D03CB42D848CBB0B0AF023A87FA65 0bc403eb0000000000000000000000113403 2018-12-29 23:00:00 sent transactional
Add Comment
Please, Sign In to add comment