title: Read in .xlsx with csv module in python
body: <p>I'm trying to read in an excel file with .xlsx formatting with the <code>csv</code> module, but I'm not having any luck with it when using an excel file even with my dialect and encoding specified. Below, I show my different attempts and error results with the different encodings I tried. If anyone could point me into the correct coding, syntax or module I could use to read in a .xlsx file in Python, I'd appreciate it. </p>
  
  <p>With the below code, I get the following error: <code>_csv.Error: line contains NULL byte</code></p>
  
  <pre><code>#!/usr/bin/python
  
  import sys, csv
  
  with open('filelocation.xlsx', "r+", encoding="Latin1")  as inputFile:
      csvReader = csv.reader(inputFile, dialect='excel')
      for row in csvReader:
          print(row)
  </code></pre>
  
  <p>With the below code, I get the following error: <code>UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcc in position 16: invalid continuation byte</code></p>
  
  <pre><code>#!/usr/bin/python
  
  import sys, csv
  
  with open('filelocation.xlsx', "r+", encoding="Latin1")  as inputFile:
      csvReader = csv.reader(inputFile, dialect='excel')
      for row in csvReader:
          print(row)
  </code></pre>
  
  <p>When I use <code>utf-16</code> in the <code>encoding</code>, I get the following error: <code>UnicodeDecodeError: 'utf-16-le' codec can't decode bytes in position 570-571: illegal UTF-16 surrogate</code></p>