Python
Public
Simple CSV Reader
Read a CSV file with headers and print selected columns.
#python
#csv
#file
#student
Python
import csv
with open("students.csv", newline="", encoding="utf-8") as file:
reader = csv.DictReader(file)
for row in reader:
name = row.get("name", "")
grade = row.get("grade", "")
print(f"{name}: {grade}")
Notes
DictReader is useful when the first row contains column names.