I have a customer care call log in an excel sheet. Below is the format of the data i have
So# Comments
1 sjhsh QUOTE 234566
1 sdsds customer call QUote 239876 Call back
2 adsdfh unknown call from customer QUOTE 189067 sdkjsd woieweio
3 QUOTE 657894 customer called for service
I am reading this data from excel and need to get 6 digits afetr the text "QUOTE" in each row and then add the extracted digits as a new column
1.The rows might have multiple "QUOTE" mentions 2.The rows might not have "QUOTE"at all
Can someone please help me out with this substring search using python
import pandas as pd
import re
file=pd.read_excel("C:/Users/rkatta/Desktop/Book1.xlsx")
file.set_index('Index', inplace=True, drop=True)
comments=file['InternalComments']
quotenum=[]
keyword= 'QUOTE'
for i in comments:
try:
befor_keyowrd, keyword, after_keyword = comments[i].partition(keyword)
num=after_keyword[:6]
quotenum.append(num)
except AttributeError:
befor_keyowrd, keyword, after_keyword =''
quotenum.append(after_keyword)