79377657

Date: 2025-01-22 12:17:01
Score: 1.5
Natty:
Report link

You need to change the open mode to text. I came upon this on the documentation, and this example is not working:

https://docs.python.org/3.11/library/collections.html#namedtuple-factory-function-for-tuples-with-named-fields :

EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, paygrade')
import csv
for emp in map(EmployeeRecord._make, csv.reader(open("employees.csv", "rb"))):
    print(emp.name, emp.title)
Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: hchakroun