title: How can I validate the double quotes of values in a pipe delimited file using Python?
body: <p>I have a pipe delimited file in S3, where rows look like this:</p>
  
  <pre><code>123 | "val 2" | "" | """ | | val5
  </code></pre>
  
  <p>I'm reading the bytestream and converting it to a dictionary using csv.DictReader:</p>
  
  <pre><code>data_iter = stream_from_s3_utf8(s3_stream)
  csv_iter = csv.DictReader(data_iter)
  </code></pre>
  
  <p>When I use packages to convert the contents of a file to python code, these packages (sensibly) infer that double quotes are just an indicator that some value is supposed to be a string, so "val 2" (with literal double quotes in the file) goes into my dictionary as a string value without any quotes. And both an empty value (the fifth value above) and a pair of double quotes (the third value above) go into my dictionary as an empty string. But I need to validate the quoting in my file, so I need access to the literal quotes. (For example, the third value above is not valid, but the fifth is.) Is there any way in Python to read the contents of a file while preserving the quotes?</p>