Question

Were working with a csv file, which contains employee information. Each record has a name field, followed by a phone number

1 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

If you have any doubts please comment below. Please give upvote if you like this.

Python Code:

#Import re module

import re

#Method to transform records

def transform_record( record ):

  #Apply sub method it replace the pattern math in a string

  new_record = re.sub("\d{3}-\d{3}-\d{4}|\d{3}-\d{7}","+1-"+record.split(",")[1],record)

  #Return the result string

  return new_record

  

# Here display the results based on problem

print(transform_record("Sabrina Green,802-867-5309,System Administrator"))

print(transform_record("Eli Jones,684-3481127,IT Specialist"))

print(transform_record("Melody Daniels,846-687-7436,Programmer"))

print(transform_record("Charlie Revera,698-746-3357,Web Developer"))

6 7 1 #Import re module 2 import re 3 #Method to transform records 4 def transform_record record ): 5 #Apply sub method it re

Add a comment
Know the answer?
Add Answer to:
We're working with a csv file, which contains employee information. Each record has a name field,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT