.. ot-exercise:: python.exercises.userdb.csvreader_function :dependencies: python.exercises.userdb.csvreader, python.basics.python_0270_functions .. include:: Exercise: Refactoring - Extract CSV Reading Into Function (``csv.reader``) ========================================================================== .. contents:: :local: Requirement ----------- Following :doc:`csvreader`, refactor ``read-userdb.py`` to not directly output the user records as specified. Rather, create a function that reads the CSV file, and returns a list of user records - dictionaries with specified keys - of the form, .. code-block:: python { 'id': 2, # int 'firstname': 'Jörg', 'lastname': 'Faschingbauer', 'birth': '19.6.1966', } That list is then used as follows in the main part of the program (the part that creates the output which remains the same): .. code-block:: python user_records = read_csv_noheader(filename) for rec in user_records: ... create output like before, no change ... Dependencies ------------ .. ot-graph:: :entries: python.exercises.userdb.csvreader_function