我正在使用下面的Python脚本为具有多个标签的Excel工作表制作CSV。即使它没有出错并打印出“CSVs made”,我也无法在任何应该生成的CSV中找到它。我做了一些更改,但仍然返回空白。
def Excel2CSV(ExcelFile, Sheetname, CSVFile):
import xlrd
import csv
file_location = "C:\Users\aqureshi\Desktop\Programming\consolidateddataviewsyellowed.xlsx"
workbook = xlrd.open_workbook(file_location)
worksheet = workbook.sheet_by_name ("ARC")
csvfile = open (ARC.csv,'wb')
wr = csv.writer (csvfile, quoting = csv.QUOTE_ALL)
for rownum in xrange (worksheet.nrows):
wr.writerow(
list(x.encode('utf-8') if type (x) == type (u'') else x
for x in worksheet.row_values (rownum)))
csvfile.close()
print(Excel2CSV())
非常感谢任何帮助。