CSV files
● can be viewed in spreadsheets
● module CSV has to be imported
Text files
● can be viewed in the text editor
● No specific module required to be imported
import csv
def COURIER_ADD() :
f1=open("courier.csv","a",newline="\n")
writ=csv.writer(f1)
cid=int(input("Enter the Courier id"))
s_name=input ("Enter the Sender Name")
Source=input("Enter the Source Address")
destination=input("Enter Destination Name")
detail=[cid,s_name,Source,destination]
writ.writerow (detail)
f1.close()
def COURIER_SEARCH() :
f1=open("courier.csv","r") # ignore newline
detail=csv.reader(f1)
name=input("Enter the Destination Name to be searched")
for i in detail :
if i[3]==name:
print("Details of courier are: ",i)
COURIER_ADD()
COURIER_SEARCH()