title: How to unzip gz file and and then use csv file?
body: <p>I have been trying to unzip a .gz file and create a csv file from it. Then I need to sort that csv file. However, I keep getting errors after creating the csv file and sorting it.</p>
  <p>I have created the file like so:</p>
  <pre><code>with gzip.open(&quot;test.csv.gz&quot;, 'rb') as f_in:
         with open(&quot;test.csv&quot;, 'wb') as f_out:
             shutil.copyfileobj(f_in, f_out)
  </code></pre>
  <p>After creating the file I read in the sorted csv file like this:</p>
  <pre><code>with open(filename, 'r') as input:
      reader = csv.DictReader(input, delimiter='\t')
      first_row = next(reader)
  </code></pre>
  <p>However I keep getting the following error from the last line of the above code.</p>
  <pre class="lang-none prettyprint-override"><code>UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
  </code></pre>
  <p>What am I doing wrong with either opening unzipping the gz file or opening the csv file?</p>