Computer Science
What is the following code doing?
import csv
File = open("contacts.csv", "a")
Name = input("Please enter name: ")
Phno = input("Please enter phone number: ")
data = [Name, Phno]
csvwriter = csv.writer(File)
csvwriter.writerow(data)
File.close()
Related Questions
Write statements to open a binary file C:\Myfiles\Text1.txt in read and write mode by specifying file path in two different formats.
Write a statement in Python to perform the following operations:
(a) To open a text file "BOOK.TXT" in read and append mode
(b) To open a text file "BOOK.TXT" in write mode
(c) To open a text file "BOOK.TXT" in append mode
Write code to open the file in the previous question and print it in the following form:
Name : <name> Phone: <phone number>
Consider the file "contacts.csv" created in above Q. and figure out what the following code is trying to do?
name = input("Enter name :") file = open("contacts.csv", "r") for line in file: if name in line: print(line)