0% found this document useful (0 votes)
4 views1 page

Python CSV Basics Worksheet

The document contains a Python script for managing a CSV file of furniture data, allowing users to add records and search for items based on price. The 'ADD' function writes furniture details to 'furdatas.csv', while the 'Search' function retrieves and prints records with prices greater than 10,000. It includes user prompts for input and options to continue or exit the data entry process.

Uploaded by

Vansh Kapla
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Python CSV Basics Worksheet

The document contains a Python script for managing a CSV file of furniture data, allowing users to add records and search for items based on price. The 'ADD' function writes furniture details to 'furdatas.csv', while the 'Search' function retrieves and prints records with prices greater than 10,000. It includes user prompts for input and options to continue or exit the data entry process.

Uploaded by

Vansh Kapla
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Worksheet

Python Basics -CSV File


Lovejeet Arora
With Answer Key

import csv
def ADD():
FileCSV=open("[Link]","w",newline="")
CSVW=[Link](FileCSV)
[Link](["fid","fname","fprice"])
while True:
fid=int(input("Enter furniture Id"))
fname=input("Enter furniture Name")
fprice=int(input("Enter furniture Price"))
List=[fid,fname,fprice]
[Link](List)
Ch=int(input("Do you Want to wnter more records if yes
press 1 or to Exit Press 2"))
if Ch!=1:
break

def Search():
FileCSV = open("[Link]", "r")
next(FileCSV)
Data=[Link](FileCSV)
for i in Data:
if int(i[2])>10000:
print(i)

Search()

You might also like