title: Read CSV file into HTML tables with Python
body: <p>I'm needing to input data from a CSV file and create a HTML table as the output.</p>
  
  <p>I am currently working with:</p>
  
  <pre><code>with open('2016motogp.csv') as csvfile:
   reader = csv.DictReader(csvfile, delimiter='\t')
   for row in reader:
       print('&lt;tr&gt;')
       for fn in reader.fieldnames:
           print('&lt;td&gt;{}&lt;/td&gt;'.format(row[fn]))
       print('&lt;/tr&gt;')
  </code></pre>
  
  <p>The CSV file I want to read into the table is:
  <a href="https://ufile.io/6joj6" rel="nofollow noreferrer">https://ufile.io/6joj6</a></p>
  
  <p>When I run the function I get the error:</p>
  
  <pre><code>    ---------------------------------------------------------------------------
  UnicodeDecodeError                        Traceback (most recent call last)
  &lt;ipython-input-11-3a27549e50fe&gt; in &lt;module&gt;()
  ----&gt; 1 write_html_table("2016motogp")
  
  &lt;ipython-input-9-91d2a78b30ad&gt; in write_html_table(filename)
       55     with open(filename + ".csv") as csvfile:
       56         reader = csv.DictReader(csvfile, delimiter='\t')
  ---&gt; 57         for row in reader:
       58             print('&lt;tr&gt;')
       59             for fn in reader.fieldnames:
  
  E:\Anaconda\lib\csv.py in __next__(self)
      109         if self.line_num == 0:
      110             # Used only for its side effect.
  --&gt; 111             self.fieldnames
      112         row = next(self.reader)
      113         self.line_num = self.reader.line_num
  
  E:\Anaconda\lib\csv.py in fieldnames(self)
       96         if self._fieldnames is None:
       97             try:
  ---&gt; 98                 self._fieldnames = next(self.reader)
       99             except StopIteration:
      100                 pass
  
  E:\Anaconda\lib\encodings\cp1252.py in decode(self, input, final)
       21 class IncrementalDecoder(codecs.IncrementalDecoder):
       22     def decode(self, input, final=False):
  ---&gt; 23         return codecs.charmap_decode(input,self.errors,decoding_table)[0]
       24 
       25 class StreamWriter(Codec,codecs.StreamWriter):
  
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 1037: character maps to &lt;undefined&gt;
  </code></pre>
  
  <p>If anybody provide some guidance or help out it would be much appreciated.</p>
  
  <p>Thanks in advance,</p>