digital-cognition-co-in / DigitalCognition

DigitalCognition - Main repo - Core Product
2 stars 2 forks source link

Validation of Phone Numbers in a String using REGEX #29

Open RohitDhankar opened 4 years ago

RohitDhankar commented 4 years ago

1/ In a pandas DF - Check for phone numbers in a String 2/ If a valid Number extract the number and populate in a New Column of DF 3/ If no valid Number - then write "No_Valid_Tele" to the New Column 4/ Phone Numbers can be International Phone Numbers as an example an Austrian Number will start with Country Code = Austria (AT) countryCode=43 , while an Indian one with countryCode= 91. 5/ We need to extract Country code and then in a New Column of DF , provide the Country Code and Country Name

Phones Validation - re.compile("(0/91)?[7-9][0-9]{9}") https://pypi.org/project/phonenumbers/ https://stackoverflow.com/questions/15258708/python-trying-to-check-for-a-valid-phone-number https://stackoverflow.com/questions/16135069/python-validation-mobile-number

Don think there is a public dataset of phone numbers to test , for international numbers We can try this XML file and convert from XML to CSV file to create our own test data sets ... need to pick this from XML file == Austria (AT) countryCode=43 , and the Mobile numbers etc ... also given Regex Patterns in this XML file can be used .

https://github.com/daviddrysdale/python-phonenumbers/blob/dev/resources/PhoneNumberAlternateFormats.xml https://pypi.org/project/xmlutils/1.1/ http://blog.appliedinformaticsinc.com/how-to-parse-and-convert-xml-to-csv-using-python/

abhijeetmote commented 4 years ago

Hi Rohit, Following is the code, today I will update the final code. I was busy with office stuff, so couldn't make it. xml_parser.txt

abhijeetmote commented 4 years ago

Hi Rohit, Following is the updated version of the code. Kindly suggest if any code changes needed.

xmlparsing.txt

Thanks & Regards, Abhijeet