Q. Write code to open file created in previous question and print it in following form:
Name : <name> Phone :< phone number>
Answer :-
file = open("contacts.csv", "r") data = file.readlines() for i in data : for j in range(len(i) +1 ) : if i[ j ].isdigit() : print("Name :",i[ : j-1]," Phone :",i[ j : ]) break
Output :-
Let contact.csv contains :-
Path | 1234567890 |
Portal | 5796423891 |
Walla | 1357926480 |
Express | 4668446545 |
So, Output :-
Name : Path Phone : 1234567890
Name : Portal Phone : 5796423891
Name : Walla Phone : 1357926480
Name : Express Phone : 4668446545
>>>
Name : Portal Phone : 5796423891
Name : Walla Phone : 1357926480
Name : Express Phone : 4668446545
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )