prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  read_csv - Key 'Name' was not found in the CSV header fields
  ##### SUMMARY
  The `read_csv` module fails to identify a field, yet displaces the field in the list of available fields.
  
  ##### ISSUE TYPE
  - Bug Report
  
  ##### COMPONENT NAME
  read_csv
  
  ##### ANSIBLE VERSION
  
  ```
  ansible 2.9.10
    config file = /home/anton/git/ansible-deploy-vmware-vm/ansible.cfg
    configured module search path = ['/home/anton/git/ansible-deploy-vmware-vm/library']
    ansible python module location = /home/anton/.local/lib/python3.6/site-packages/ansible
    executable location = /home/anton/.local/bin/ansible
    python version = 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0]
  
  ```
  
  ##### CONFIGURATION
  
  ```
  # config file for ansible -- http://ansible.com/
  # ==============================================
  
  # nearly all parameters can be overridden in ansible-playbook
  # or with command line flags. ansible will read ANSIBLE_CONFIG,
  # ansible.cfg in the current working directory, .ansible.cfg in
  # the home directory or /etc/ansible/ansible.cfg, whichever it
  # finds first
  
  [defaults]
  host_key_checking = False
  host_key_check = False
  ansible_python_interpreter=/usr/bin/python3
  log_path = ./ansible.log
  #bin_ansible_callbacks=True
  #stdout_callback = debug
  
  
  # some basic default values...
  library        = ./library
  
  # additional paths to search for roles in, colon separated
  roles_path    = ./roles
  
  [ssh_connection]
  # ssh arguments to use
  ssh_args = -o StrictHostKeyChecking=no
  timeout=60
  
  
  ```
  
  ##### OS / ENVIRONMENT
  Ubuntu 20:04
  
  
  ##### STEPS TO REPRODUCE
  <!--- Describe exactly how to reproduce the problem, using a minimal test-case -->
  
  <!--- Paste example playbooks or commands between quotes below -->
  ```
  ---
  - name: Right-size VMs
    gather_facts: false
    hosts: all
    connection: local
    tasks:
      # Read a CSV file and access the first item
    - name: Read users from CSV file and return a list
      read_csv:
          path: "files/vms/6-19-20 Optimization Report - Oversized Virtual Machines Prod2.csv"
          key: Name
      register: users
  
    - debug:
        msg: 'User {{ users.list.2.Name}}'
          # msg: 'User {{ users.list.2.Name}} has UID {{ users.list.2.ReclaimablevCPUs}} and GID {{ users.list.2.ReclaimableMemory}}'
          # msg: "{{ users }}"
  
  
  
  ```
  
  <!--- HINT: You can paste gist.github.com links for larger files -->
  
  ##### EXPECTED RESULTS
  Expect to be able to read CSV values by col name (field) as based on module documentation.
  
  
  ##### ACTUAL RESULTS
  ```
  fatal: [localhost]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "Key 'Name' was not found in the CSV header fields: ﻿Name, Configured-vCPU, ReclaimablevCPUs, ConfiguredMemory, ReclaimableMemory, ParentvCenter"}
  ```
  
  
  
  
  </issue>
  <code>
  [start of plugins/module_utils/csv.py]
  1 # -*- coding: utf-8 -*-
  2 
  3 # Copyright (c) 2021, Andrew Pantuso (@ajpantuso) <ajpantuso@gmail.com>
  4 # Copyright (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
  5 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
  6 # SPDX-License-Identifier: GPL-3.0-or-later
  7 
  8 from __future__ import absolute_import, division, print_function
  9 __metaclass__ = type
  10 
  11 import csv
  12 from io import BytesIO, StringIO
  13 
  14 from ansible.module_utils.common.text.converters import to_native
  15 from ansible.module_utils.six import PY3
  16 
  17 
  18 class CustomDialectFailureError(Exception):
  19     pass
  20 
  21 
  22 class DialectNotAvailableError(Exception):
  23     pass
  24 
  25 
  26 CSVError = csv.Error
  27 
  28 
  29 def initialize_dialect(dialect, **kwargs):
  30     # Add Unix dialect from Python 3
  31     class unix_dialect(csv.Dialect):
  32         """Describe the usual properties of Unix-generated CSV files."""
  33         delimiter = ','
  34         quotechar = '"'
  35         doublequote = True
  36         skipinitialspace = False
  37         lineterminator = '\n'
  38         quoting = csv.QUOTE_ALL
  39 
  40     csv.register_dialect("unix", unix_dialect)
  41 
  42     if dialect not in csv.list_dialects():
  43         raise DialectNotAvailableError("Dialect '%s' is not supported by your version of python." % dialect)
  44 
  45     # Create a dictionary from only set options
  46     dialect_params = dict((k, v) for k, v in kwargs.items() if v is not None)
  47     if dialect_params:
  48         try:
  49             csv.register_dialect('custom', dialect, **dialect_params)
  50         except TypeError as e:
  51             raise CustomDialectFailureError("Unable to create custom dialect: %s" % to_native(e))
  52         dialect = 'custom'
  53 
  54     return dialect
  55 
  56 
  57 def read_csv(data, dialect, fieldnames=None):
  58 
  59     data = to_native(data, errors='surrogate_or_strict')
  60 
  61     if PY3:
  62         fake_fh = StringIO(data)
  63     else:
  64         fake_fh = BytesIO(data)
  65 
  66     reader = csv.DictReader(fake_fh, fieldnames=fieldnames, dialect=dialect)
  67 
  68     return reader
  69
  [end of plugins/module_utils/csv.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/plugins/module_utils/csv.py b/plugins/module_utils/csv.py
  --- a/plugins/module_utils/csv.py
  +++ b/plugins/module_utils/csv.py
  @@ -55,8 +55,10 @@
   
   
   def read_csv(data, dialect, fieldnames=None):
  -
  +    BOM = to_native(u'\ufeff')
       data = to_native(data, errors='surrogate_or_strict')
  +    if data.startswith(BOM):
  +        data = data[len(BOM):]
   
       if PY3:
           fake_fh = StringIO(data)
  
verification_info: {"golden_diff": "diff --git a/plugins/module_utils/csv.py b/plugins/module_utils/csv.py\n--- a/plugins/module_utils/csv.py\n+++ b/plugins/module_utils/csv.py\n@@ -55,8 +55,10 @@\n \n \n def read_csv(data, dialect, fieldnames=None):\n-\n+    BOM = to_native(u'\\ufeff')\n     data = to_native(data, errors='surrogate_or_strict')\n+    if data.startswith(BOM):\n+        data = data[len(BOM):]\n \n     if PY3:\n         fake_fh = StringIO(data)\n", "issue": "read_csv - Key 'Name' was not found in the CSV header fields\n##### SUMMARY\r\nThe `read_csv` module fails to identify a field, yet displaces the field in the list of available fields.\r\n\r\n##### ISSUE TYPE\r\n- Bug Report\r\n\r\n##### COMPONENT NAME\r\nread_csv\r\n\r\n##### ANSIBLE VERSION\r\n\r\n```\r\nansible 2.9.10\r\n  config file = /home/anton/git/ansible-deploy-vmware-vm/ansible.cfg\r\n  configured module search path = ['/home/anton/git/ansible-deploy-vmware-vm/library']\r\n  ansible python module location = /home/anton/.local/lib/python3.6/site-packages/ansible\r\n  executable location = /home/anton/.local/bin/ansible\r\n  python version = 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0]\r\n\r\n```\r\n\r\n##### CONFIGURATION\r\n\r\n```\r\n# config file for ansible -- http://ansible.com/\r\n# ==============================================\r\n\r\n# nearly all parameters can be overridden in ansible-playbook\r\n# or with command line flags. ansible will read ANSIBLE_CONFIG,\r\n# ansible.cfg in the current working directory, .ansible.cfg in\r\n# the home directory or /etc/ansible/ansible.cfg, whichever it\r\n# finds first\r\n\r\n[defaults]\r\nhost_key_checking = False\r\nhost_key_check = False\r\nansible_python_interpreter=/usr/bin/python3\r\nlog_path = ./ansible.log\r\n#bin_ansible_callbacks=True\r\n#stdout_callback = debug\r\n\r\n\r\n# some basic default values...\r\nlibrary        = ./library\r\n\r\n# additional paths to search for roles in, colon separated\r\nroles_path    = ./roles\r\n\r\n[ssh_connection]\r\n# ssh arguments to use\r\nssh_args = -o StrictHostKeyChecking=no\r\ntimeout=60\r\n\r\n\r\n```\r\n\r\n##### OS / ENVIRONMENT\r\nUbuntu 20:04\r\n\r\n\r\n##### STEPS TO REPRODUCE\r\n<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```\r\n---\r\n- name: Right-size VMs\r\n  gather_facts: false\r\n  hosts: all\r\n  connection: local\r\n  tasks:\r\n    # Read a CSV file and access the first item\r\n  - name: Read users from CSV file and return a list\r\n    read_csv:\r\n        path: \"files/vms/6-19-20 Optimization Report - Oversized Virtual Machines Prod2.csv\"\r\n        key: Name\r\n    register: users\r\n\r\n  - debug:\r\n      msg: 'User {{ users.list.2.Name}}'\r\n        # msg: 'User {{ users.list.2.Name}} has UID {{ users.list.2.ReclaimablevCPUs}} and GID {{ users.list.2.ReclaimableMemory}}'\r\n        # msg: \"{{ users }}\"\r\n\r\n\r\n\r\n```\r\n\r\n<!--- HINT: You can paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\nExpect to be able to read CSV values by col name (field) as based on module documentation.\r\n\r\n\r\n##### ACTUAL RESULTS\r\n```\r\nfatal: [localhost]: FAILED! => {\"ansible_facts\": {\"discovered_interpreter_python\": \"/usr/bin/python\"}, \"changed\": false, \"msg\": \"Key 'Name' was not found in the CSV header fields: \ufeffName, Configured-vCPU, ReclaimablevCPUs, ConfiguredMemory, ReclaimableMemory, ParentvCenter\"}\r\n```\r\n\r\n\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright (c) 2021, Andrew Pantuso (@ajpantuso) <ajpantuso@gmail.com>\n# Copyright (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>\n# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)\n# SPDX-License-Identifier: GPL-3.0-or-later\n\nfrom __future__ import absolute_import, division, print_function\n__metaclass__ = type\n\nimport csv\nfrom io import BytesIO, StringIO\n\nfrom ansible.module_utils.common.text.converters import to_native\nfrom ansible.module_utils.six import PY3\n\n\nclass CustomDialectFailureError(Exception):\n    pass\n\n\nclass DialectNotAvailableError(Exception):\n    pass\n\n\nCSVError = csv.Error\n\n\ndef initialize_dialect(dialect, **kwargs):\n    # Add Unix dialect from Python 3\n    class unix_dialect(csv.Dialect):\n        \"\"\"Describe the usual properties of Unix-generated CSV files.\"\"\"\n        delimiter = ','\n        quotechar = '\"'\n        doublequote = True\n        skipinitialspace = False\n        lineterminator = '\\n'\n        quoting = csv.QUOTE_ALL\n\n    csv.register_dialect(\"unix\", unix_dialect)\n\n    if dialect not in csv.list_dialects():\n        raise DialectNotAvailableError(\"Dialect '%s' is not supported by your version of python.\" % dialect)\n\n    # Create a dictionary from only set options\n    dialect_params = dict((k, v) for k, v in kwargs.items() if v is not None)\n    if dialect_params:\n        try:\n            csv.register_dialect('custom', dialect, **dialect_params)\n        except TypeError as e:\n            raise CustomDialectFailureError(\"Unable to create custom dialect: %s\" % to_native(e))\n        dialect = 'custom'\n\n    return dialect\n\n\ndef read_csv(data, dialect, fieldnames=None):\n\n    data = to_native(data, errors='surrogate_or_strict')\n\n    if PY3:\n        fake_fh = StringIO(data)\n    else:\n        fake_fh = BytesIO(data)\n\n    reader = csv.DictReader(fake_fh, fieldnames=fieldnames, dialect=dialect)\n\n    return reader\n", "path": "plugins/module_utils/csv.py"}]}