title: Efficiently formatting every item in a Python list
body: <p>I am processing a CSV file. My code reads the file and returns a list for every row, where each element in the list represents a different field. At the moment there are 67 elements in each list and there could be thousands of rows.</p>
  <p>This is the code the reads and processes the CSV:</p>
  <pre><code>def parse_quoted_csv(file_contents):
      &quot;&quot;&quot;Parse a CSV file where each element is double-quoted&quot;&quot;&quot;
  
      # split the file into separate lines
      lines = file_contents.splitlines()
  
      # create a csv reader
      reader = csv.reader(
          lines,
          quotechar='&quot;',
          delimiter=&quot;,&quot;,
          quoting=csv.QUOTE_ALL,
          skipinitialspace=True,
      )
  
      # reader is an iterator, skip the first line
      next(reader, None)
  
      # yield the results
      for line in reader:
          yield line
  </code></pre>
  <p>Here's an example of what one might look like:</p>
  <pre><code>['U1234567', 'Individual', '', 'USD', 'STK', 'MSFT', 'MICROSOFT, CORP', '272093', 'US5949181045', 'ISIN', '594918104', 'US5949181045', 'NASDAQ', '', '', '', '', '', '1', '', '', '', '', '', '', '2364593439', '', '', '', '', '', '', '', '', '20220411;094043', '20220411;094043', '20220411', '20220413', '20220411', '', 'BUY', '10', '289.29', '2892.9', '-2892.9', '-1', '', '', '', '', '', '', 'USD', '0', '', 'LMT', 'ORDER', '', '', '', '0', '', '', '', '', '0.0', '0.0 ()']
  </code></pre>
  <p>I need to iterate through every item in the list. Each item will be checked and some will be formatted from a string to a <code>datetime</code> object or <code>Decimal</code> type.</p>
  <p>(I'm doing this to insert the record into my DynamoDB table.)</p>
  <p>For example, I would apply the following to the element at index 35 <code>20220411;094043</code>:</p>
  <pre><code>dt.datetime.strptime(d, '%Y%m%d;%H%M%S')
  </code></pre>
  <p>What is the most efficient way to apply formatting to every element in the list?</p>
  <p>Note: I don't have access to pandas. I'm only using methods from the Python standard library.</p>