当前,我的程序可以打开和读取文件夹中的所有.xlsx文件。然后,可以将它们一个一个地写入.csv文件。但是,它将在每行之后添加一个空白行,并将Int转换为我不想要的Float。差不多是新手。
root = tkinter.Tk()
root.withdraw()
path = tkinter.filedialog.askdirectory(parent=root,title='Select the directory with the assignments to grade')
folder = os.listdir(path)
with open('csvConsolidatedFile.csv', 'wb', delimiter=' ', lineterminator='\n') as outfile:
wr = csv.writer(outfile)
for xlsFile in folder:
document = os.path.join(path, xlsFile)
wb = xlrd.open_workbook(document)
for index in range(1,2):
sh = wb.sheet_by_name('Sheet' + str(index))
for rownum in range(sh.nrows):
wr.writerow(sh.row_values(rownum))
csvConsolidatedFile.close()