Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import csv
- import sys
- def searchName():
- N = input("Enter name to search with: ")
- with open("AddressBook.csv", "r") as f:
- reader = csv.reader(f)
- for row in reader:
- for field in row:
- if field == N:
- print(row)
- def searchMonth():
- dob = input('Input dob (DD/MM/YYYY): ')
- date, month, year = dob.split("/")
- with open('AddressBook.csv', newline='') as myfile:
- reader = csv.reader(myfile)
- for row in reader:
- row_date, row_month, row_year = row[6].split("/")
- if row_month == month:
- print(row)
- method = input("Enter:n1-Search by Namen2-Search by Month of Birth")
- if method == '1':
- searchName()
- elif method == '2':
- searchMonth()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement