我有多个excel文件。所有excel中的数据集都在表单1中。我想从特定行(6734)和所有excelss中的列中选择数据,并将所有选取的值附加到新的excel或csv文件中。
我写了代码但没有工作
import os
import xlwt
import xlrd
index=0
workbook = xlwt.Workbook()
Testsheet = workbook.add_sheet('test')
print ("Enter the row you want")
row=input(6374)
print ("Enter the column you want")
col=input(1)
path= 'E:/Vishal_Work/Rapti_Flood_Work/Rainfall_data/imdforecasteddata'
for root,dirs,files in os.walk(path):
xlsfiles=[ _ for _ in files if _.endswith('.xlsx') ]
for xlsfile in xlsfiles:
wb = xlrd.open_workbook(os.path.join(root,xlsfile))
n = len(wb.sheets())
for s in range(n) :
sheet = wb.sheet_by_index(s)
data=sheet.cell(row,col).value
print (data)
Testsheet.write(index, 0, data)
index=index+1
workbook.save('Test.xlsx')