Q. Write a program to read from a file Items.csv and create a file highitems.csv, containing only those item details from Items.csv where price > 250.
Answer :-
import csv file = open("Itemnew.csv","r", newline = "\n") data = csv.reader( file , delimiter = "|" ) for i in data : if float(i [2] ) > 250 : print(i) file.close()
Output :-
['41286', 'PathWalla', '999.99', 'Website']
['87456', 'Python', '285.9', 'Programing language']
>>>
['87456', 'Python', '285.9', 'Programing language']
>>>
This is incomplete as it does not create a new file and import the data
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )