Spliting all three attributes of this list
[8352] Marilyn Hudson - 16000 Views
This is the instance that I get from FacebookAdsAPi
I have been trying a separate list into 3 attributes separately.
I have used client.split("]")[1]
But it gives me Marilyn Hudson - 16000 Views. How can i get all three attributes seperately?
Expected output -
id >> 8352
name >> Marilyn Hudson
impressions >> 16000
TIA
django python-3.x split
add a comment |
[8352] Marilyn Hudson - 16000 Views
This is the instance that I get from FacebookAdsAPi
I have been trying a separate list into 3 attributes separately.
I have used client.split("]")[1]
But it gives me Marilyn Hudson - 16000 Views. How can i get all three attributes seperately?
Expected output -
id >> 8352
name >> Marilyn Hudson
impressions >> 16000
TIA
django python-3.x split
What's the question here?
– AkshayNevrekar
Nov 14 '18 at 10:39
What is the expected output?
– Mayank Porwal
Nov 14 '18 at 10:52
@AkshayNevrekar how can i get all three attributes seperately?
– ans2human
Nov 14 '18 at 11:02
add a comment |
[8352] Marilyn Hudson - 16000 Views
This is the instance that I get from FacebookAdsAPi
I have been trying a separate list into 3 attributes separately.
I have used client.split("]")[1]
But it gives me Marilyn Hudson - 16000 Views. How can i get all three attributes seperately?
Expected output -
id >> 8352
name >> Marilyn Hudson
impressions >> 16000
TIA
django python-3.x split
[8352] Marilyn Hudson - 16000 Views
This is the instance that I get from FacebookAdsAPi
I have been trying a separate list into 3 attributes separately.
I have used client.split("]")[1]
But it gives me Marilyn Hudson - 16000 Views. How can i get all three attributes seperately?
Expected output -
id >> 8352
name >> Marilyn Hudson
impressions >> 16000
TIA
django python-3.x split
django python-3.x split
edited Nov 14 '18 at 11:04
ans2human
asked Nov 14 '18 at 10:38
ans2humanans2human
624511
624511
What's the question here?
– AkshayNevrekar
Nov 14 '18 at 10:39
What is the expected output?
– Mayank Porwal
Nov 14 '18 at 10:52
@AkshayNevrekar how can i get all three attributes seperately?
– ans2human
Nov 14 '18 at 11:02
add a comment |
What's the question here?
– AkshayNevrekar
Nov 14 '18 at 10:39
What is the expected output?
– Mayank Porwal
Nov 14 '18 at 10:52
@AkshayNevrekar how can i get all three attributes seperately?
– ans2human
Nov 14 '18 at 11:02
What's the question here?
– AkshayNevrekar
Nov 14 '18 at 10:39
What's the question here?
– AkshayNevrekar
Nov 14 '18 at 10:39
What is the expected output?
– Mayank Porwal
Nov 14 '18 at 10:52
What is the expected output?
– Mayank Porwal
Nov 14 '18 at 10:52
@AkshayNevrekar how can i get all three attributes seperately?
– ans2human
Nov 14 '18 at 11:02
@AkshayNevrekar how can i get all three attributes seperately?
– ans2human
Nov 14 '18 at 11:02
add a comment |
1 Answer
1
active
oldest
votes
If I understand correctly,
In [1912]: client
Out[1912]: '[8352] Marilyn Hudson - 16000 Views'
In [1930]: new_list.append(re.findall(r'd+', client.split('-')[0])[0])
In [1931]: new_list.append(client.split('-')[0].split('] ')[1].strip())
In [1932]: new_list.append(client.split('-')[1].strip())
In [1933]: new_list
Out[1933]: ['8352', 'Marilyn Hudson', '16000 Views']
Let me know if this helps.
Thanks alot @Mayank. It works like a charm.
– ans2human
Nov 14 '18 at 11:09
Happy to help. @ans2human
– Mayank Porwal
Nov 14 '18 at 11:10
in our last split method for views i just need the number, which i have acheived using other regex but in some cases the data is like this -[8352] Marilyn Hudson - 499 for 16000 Views. So i just need to get 16000 but with your method i get 499. Can you help me?
– ans2human
Nov 20 '18 at 14:14
1
Sure. Considerings = '[8352] Marilyn Hudson - 499 for 16000 Views'to be your string. Use thiss.split('for')[1].strip(). This will yield'16000 Views'. Ideally, you should post this as a separate question. And I should get some points for answering it. :)
– Mayank Porwal
Nov 20 '18 at 14:17
It works, i'll post it as a question and accept your answer. thnks
– ans2human
Nov 20 '18 at 14:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298227%2fspliting-all-three-attributes-of-this-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If I understand correctly,
In [1912]: client
Out[1912]: '[8352] Marilyn Hudson - 16000 Views'
In [1930]: new_list.append(re.findall(r'd+', client.split('-')[0])[0])
In [1931]: new_list.append(client.split('-')[0].split('] ')[1].strip())
In [1932]: new_list.append(client.split('-')[1].strip())
In [1933]: new_list
Out[1933]: ['8352', 'Marilyn Hudson', '16000 Views']
Let me know if this helps.
Thanks alot @Mayank. It works like a charm.
– ans2human
Nov 14 '18 at 11:09
Happy to help. @ans2human
– Mayank Porwal
Nov 14 '18 at 11:10
in our last split method for views i just need the number, which i have acheived using other regex but in some cases the data is like this -[8352] Marilyn Hudson - 499 for 16000 Views. So i just need to get 16000 but with your method i get 499. Can you help me?
– ans2human
Nov 20 '18 at 14:14
1
Sure. Considerings = '[8352] Marilyn Hudson - 499 for 16000 Views'to be your string. Use thiss.split('for')[1].strip(). This will yield'16000 Views'. Ideally, you should post this as a separate question. And I should get some points for answering it. :)
– Mayank Porwal
Nov 20 '18 at 14:17
It works, i'll post it as a question and accept your answer. thnks
– ans2human
Nov 20 '18 at 14:51
add a comment |
If I understand correctly,
In [1912]: client
Out[1912]: '[8352] Marilyn Hudson - 16000 Views'
In [1930]: new_list.append(re.findall(r'd+', client.split('-')[0])[0])
In [1931]: new_list.append(client.split('-')[0].split('] ')[1].strip())
In [1932]: new_list.append(client.split('-')[1].strip())
In [1933]: new_list
Out[1933]: ['8352', 'Marilyn Hudson', '16000 Views']
Let me know if this helps.
Thanks alot @Mayank. It works like a charm.
– ans2human
Nov 14 '18 at 11:09
Happy to help. @ans2human
– Mayank Porwal
Nov 14 '18 at 11:10
in our last split method for views i just need the number, which i have acheived using other regex but in some cases the data is like this -[8352] Marilyn Hudson - 499 for 16000 Views. So i just need to get 16000 but with your method i get 499. Can you help me?
– ans2human
Nov 20 '18 at 14:14
1
Sure. Considerings = '[8352] Marilyn Hudson - 499 for 16000 Views'to be your string. Use thiss.split('for')[1].strip(). This will yield'16000 Views'. Ideally, you should post this as a separate question. And I should get some points for answering it. :)
– Mayank Porwal
Nov 20 '18 at 14:17
It works, i'll post it as a question and accept your answer. thnks
– ans2human
Nov 20 '18 at 14:51
add a comment |
If I understand correctly,
In [1912]: client
Out[1912]: '[8352] Marilyn Hudson - 16000 Views'
In [1930]: new_list.append(re.findall(r'd+', client.split('-')[0])[0])
In [1931]: new_list.append(client.split('-')[0].split('] ')[1].strip())
In [1932]: new_list.append(client.split('-')[1].strip())
In [1933]: new_list
Out[1933]: ['8352', 'Marilyn Hudson', '16000 Views']
Let me know if this helps.
If I understand correctly,
In [1912]: client
Out[1912]: '[8352] Marilyn Hudson - 16000 Views'
In [1930]: new_list.append(re.findall(r'd+', client.split('-')[0])[0])
In [1931]: new_list.append(client.split('-')[0].split('] ')[1].strip())
In [1932]: new_list.append(client.split('-')[1].strip())
In [1933]: new_list
Out[1933]: ['8352', 'Marilyn Hudson', '16000 Views']
Let me know if this helps.
answered Nov 14 '18 at 11:03
Mayank PorwalMayank Porwal
4,8952724
4,8952724
Thanks alot @Mayank. It works like a charm.
– ans2human
Nov 14 '18 at 11:09
Happy to help. @ans2human
– Mayank Porwal
Nov 14 '18 at 11:10
in our last split method for views i just need the number, which i have acheived using other regex but in some cases the data is like this -[8352] Marilyn Hudson - 499 for 16000 Views. So i just need to get 16000 but with your method i get 499. Can you help me?
– ans2human
Nov 20 '18 at 14:14
1
Sure. Considerings = '[8352] Marilyn Hudson - 499 for 16000 Views'to be your string. Use thiss.split('for')[1].strip(). This will yield'16000 Views'. Ideally, you should post this as a separate question. And I should get some points for answering it. :)
– Mayank Porwal
Nov 20 '18 at 14:17
It works, i'll post it as a question and accept your answer. thnks
– ans2human
Nov 20 '18 at 14:51
add a comment |
Thanks alot @Mayank. It works like a charm.
– ans2human
Nov 14 '18 at 11:09
Happy to help. @ans2human
– Mayank Porwal
Nov 14 '18 at 11:10
in our last split method for views i just need the number, which i have acheived using other regex but in some cases the data is like this -[8352] Marilyn Hudson - 499 for 16000 Views. So i just need to get 16000 but with your method i get 499. Can you help me?
– ans2human
Nov 20 '18 at 14:14
1
Sure. Considerings = '[8352] Marilyn Hudson - 499 for 16000 Views'to be your string. Use thiss.split('for')[1].strip(). This will yield'16000 Views'. Ideally, you should post this as a separate question. And I should get some points for answering it. :)
– Mayank Porwal
Nov 20 '18 at 14:17
It works, i'll post it as a question and accept your answer. thnks
– ans2human
Nov 20 '18 at 14:51
Thanks alot @Mayank. It works like a charm.
– ans2human
Nov 14 '18 at 11:09
Thanks alot @Mayank. It works like a charm.
– ans2human
Nov 14 '18 at 11:09
Happy to help. @ans2human
– Mayank Porwal
Nov 14 '18 at 11:10
Happy to help. @ans2human
– Mayank Porwal
Nov 14 '18 at 11:10
in our last split method for views i just need the number, which i have acheived using other regex but in some cases the data is like this -
[8352] Marilyn Hudson - 499 for 16000 Views. So i just need to get 16000 but with your method i get 499. Can you help me?– ans2human
Nov 20 '18 at 14:14
in our last split method for views i just need the number, which i have acheived using other regex but in some cases the data is like this -
[8352] Marilyn Hudson - 499 for 16000 Views. So i just need to get 16000 but with your method i get 499. Can you help me?– ans2human
Nov 20 '18 at 14:14
1
1
Sure. Considering
s = '[8352] Marilyn Hudson - 499 for 16000 Views' to be your string. Use this s.split('for')[1].strip(). This will yield '16000 Views'. Ideally, you should post this as a separate question. And I should get some points for answering it. :)– Mayank Porwal
Nov 20 '18 at 14:17
Sure. Considering
s = '[8352] Marilyn Hudson - 499 for 16000 Views' to be your string. Use this s.split('for')[1].strip(). This will yield '16000 Views'. Ideally, you should post this as a separate question. And I should get some points for answering it. :)– Mayank Porwal
Nov 20 '18 at 14:17
It works, i'll post it as a question and accept your answer. thnks
– ans2human
Nov 20 '18 at 14:51
It works, i'll post it as a question and accept your answer. thnks
– ans2human
Nov 20 '18 at 14:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298227%2fspliting-all-three-attributes-of-this-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What's the question here?
– AkshayNevrekar
Nov 14 '18 at 10:39
What is the expected output?
– Mayank Porwal
Nov 14 '18 at 10:52
@AkshayNevrekar how can i get all three attributes seperately?
– ans2human
Nov 14 '18 at 11:02