PROGRAM 14.
CSV FILE - WITH LISTS
AIM
Write a program to create a CSV file with each record having category,
GST percentage. Create another CSV to store item details like id, name,
category, unitprice, finalprice . Read the details of 4 fields and calculate the
final price using/retrieving the gst % details from the first file.'''
PROGRAM CODING
import csv
f=open('[Link]','w',newline='')
w=[Link](f)
print('\tDetails of GST percentage of categories')
#[Link](['Category','GST%'])
while True:
cat=input('Enter category : ')
gst=int(input('Enter GST percentage : '))
data=[cat,gst]
[Link](data)
ch=input('Do you want to continue : ')
if [Link]()=='n':
break
[Link]()
f=open('[Link]','w',newline='')
w=[Link](f)
print('\tProduct details')
#[Link](['ID','Name','Category','Unitprice'])
while True:
ID=int(input('Enter product ID : '))
name=input('Enter name : ')
cat=input('Enter category : ')
unit=int(input('Enter unit price : '))
data=[ID,name,cat,unit]
[Link](data)
ch=input('Do you want to continue : ')
if [Link]()=='n':
break
[Link]()
f=open('[Link]','r')
f1=open('[Link]','r')
r=[Link](f)
r1=[Link](f1)
for i in r:
for j in r1:
if i[1].isalpha() and j[0].isalpha():
continue
else:
fin=int(j[3])+(int(j[3])*int(i[1]))/100
print('The final price of the product ',j[1],'in category ',j[2],' is',fin,'Rs')
[Link]()
[Link]()
OUTPUT
Details of GST percentage of categories
Enter category : cleaning
Enter GST percentage : 10
Do you want to continue : y
Enter category : cosmetics
Enter GST percentage : 12
Do you want to continue : n
Product details
Enter product ID : 1201
Enter name : nivea
Enter category : cosmetics
Enter unit price : 75
Do you want to continue : n
The final price of the product nivea in category cosmetics is 82.5 Rs