0
votes

Confused, need to "Write your code to print out the number of data records" - i know how to do this in pandas but not csv.DictReader

Have tried solutions from Number of lines in csv.DictReader and with len() with no success.

1
Show your code, minimal reproducible example, and explain what exactly is not as expected.buran

1 Answers

0
votes

Do you looking for to do this ?

sample.csv
"one","two","three"
4,5,6
7,8,9
import csv

with open("sample.csv") as f:
    r = csv.DictReader(f)

    print(len(list(r)))

output: 2