title: Python - Using csv and xlrd module to write multi-row excel file to one row csv file
body: <p>I've got a basic script that will take a source excel (.xlsx) file and write the data to a matching csv file in python.  My ultimate goal is take all of the data in a sheet and write it one long comma seperated row and I'm not sure how to accomplish that based on what I have so far.</p>
  
  <pre><code>def csv_from_excel():
      import csv
      import xlrd
      wb1 = raw_input('What is the path and file name of your Workbook? ')
      sh = raw_input('What is the name of the sheet being transformed? ')
      csv_file1 = raw_input('What is the file path and name of the output? ')
      print wb1
      print sh
      print csv_file1
      wb = xlrd.open_workbook(wb1)
      sh1 = wb.sheet_by_name(sh)
      csv_file = open(csv_file1, 'wb')
      wr = csv.writer(csv_file, quoting=csv.QUOTE_MINIMAL)
  
      for rownum in xrange(sh1.nrows):
          wr.writerow(sh1.row_values(rownum))
  
      csv_file.close()
      print "Completed converting %s and %s to csv" % (wb1, sh)
  
  csv_from_excel()
  </code></pre>