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

Add and Display Records Using CSV File

The document contains two Python programs that handle CSV files. The first program adds student records (roll number, name, and marks) to a CSV file named 'student.csv'. The second program reads and displays all records from the same CSV file by printing each row.

Uploaded by

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

Add and Display Records Using CSV File

The document contains two Python programs that handle CSV files. The first program adds student records (roll number, name, and marks) to a CSV file named 'student.csv'. The second program reads and displays all records from the same CSV file by printing each row.

Uploaded by

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

1.

Program to Add Records in a CSV File

Import csv

import csvdef add_record():

f = open("[Link]", "a", newline='')

writer = [Link](f)

roll = int(input("Enter Roll Number: "))

name = input("Enter Name: ")

marks = int(input("Enter Marks: "))

[Link]([roll, name, marks])

[Link]()

add_record()

2. Program to Display Records from a CSV File

(Display Records by Printing the Whole Row)

import csv

def display_records():

f = open("[Link]", "r")

reader = [Link](f)

for row in reader:

print(row)

[Link]()

display_records()

You might also like