0

I have an excel file which has data like below :

Message Type    Message Text    Message Local Date/Time
Card Admitted   Admitted 'Gulevata, Lena [Default]' (Card: 447430)   at 'EMEA-ISR-HZY 01.02.02 GF BACK DOOR [Default]' (IN).    9/17/2018 5:19
Card Admitted   Admitted 'Gulevata, Lena [Default]' (Card: 447430)   at 'EMEA-ISR-HZY 01.02.02 GF BACK DOOR [Default]' (IN).    9/17/2018 5:57
Card Admitted   Admitted 'Gulevata, Lena [Default]' (Card: 447430)   at 'EMEA-ISR-HZY 01.01.01 GF MAIN ENTRANCE [Default]' (IN).    9/17/2018 5:58
Card Admitted   Admitted 'Gulevata, Lena [Default]' (Card: 447430)   at 'EMEA-ISR-HZY 01.02.01 GF NORTH ELEVATOR LOBBY [Default]' (IN). 9/17/2018 5:59

And I want it to convert it to a dataframe like below for further processing. Basically I want to extract the Card Number from the Message Text . Any pointers using Python and Pandas would be helpful

Message Type    Message Text    Message Local Date/Time
Card Admitted   447430  9/17/2018 5:19
Card Admitted   447430  9/17/2018 5:57
Card Admitted   447430  9/17/2018 5:58
Card Admitted   447430  9/17/2018 5:59

1 Answer 1

1

you could do something along the lines of:

import pandas as pd
df = pd.read_excel(<file_name>)
df['Meassge Text'] = [x.split('card: ')[1].split(')')[0] for x in df['Meassge Text']]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.