title: Reading a gzipped file using apache beam, wrapped in TextIOWrapper results in "'CompressedFile' object has no attribute 'writable'"
body: <p>I'm working to implement a simple CSV reader in apache beam, following along with the test from the beam repo: <a href="https://github.com/apache/beam/blob/b85795adbd22d8b5cf9ebc684ce43e172a789587/sdks/python/apache_beam/io/fileio_test.py#L128-L148" rel="nofollow noreferrer">https://github.com/apache/beam/blob/b85795adbd22d8b5cf9ebc684ce43e172a789587/sdks/python/apache_beam/io/fileio_test.py#L128-L148</a></p>
  
  <pre class="lang-py prettyprint-override"><code>def get_csv_reader(readable_file):
    import sys
    import csv
    import io
    if sys.version_info &gt;= (3, 0):
      return csv.reader(io.TextIOWrapper(readable_file.open()))
    else:
      return csv.reader(readable_file.open())
  
  with beam.Pipeline() as p:
    content_pc = (p
                  | beam.Create([CSV_FILE])
                  | fileio.ReadMatches()
                  | beam.FlatMap(get_csv_reader)
                  | beam.Map(print))
  </code></pre>
  
  <p>This works correctly if CSV_FILE is not compressed and I get no errors. However, if I use a gzipped file as input, I get:</p>
  
  <pre class="lang-py prettyprint-override"><code>&lt;ipython-input-114-4830c3592163&gt; in get_csv_reader(readable_file)
        6   import io
        7   if sys.version_info &gt;= (3, 0):
  ----&gt; 8     return csv.reader(io.TextIOWrapper(readable_file.open()))
        9   else:
       10     return csv.reader(readable_file.open())
  
  AttributeError: 'CompressedFile' object has no attribute 'writable' [while running 'FlatMap(get_csv_reader)']
  </code></pre>
  
  <p>I understand why this is happening (that TextIOWrapper is looking for a readable AND writable object). Are there folks with more insight into apache beam/dataflow who can suggest how best to implement this to handle both compressed and uncompressed inputs? </p>