close
此函數為 讀入 excel 判斷 Cached 那列 為 0 時 剃除那行 , 再寫到另一個 excel
讀入 TransitionFile
寫到 ExportFile
列名 Cached
判斷為 inp 為 何數 (0 or 1)
有排序 Time & URL 這兩欄位
def writeToExcel(TransitionFile,ExportFile,Cached,inp): getCSVContent = pandas.DataFrame(pandas.read_excel(TransitionFile, header=0)) x = -1 for i in getCSVContent[Cached]: x = x + 1 if i.all() == inp: getCSVContent = getCSVContent.drop(x) data = getCSVContent.sort_values(['Time', 'URL'], ascending=True) ExcelData = pandas.DataFrame(data) book = load_workbook(ExportFile) writer = pandas.ExcelWriter(ExportFile, engine='openpyxl') writer.book = book writer.sheets = dict((ws.title, ws) for ws in book.worksheets) ExcelData.to_excel(writer, sheet_name='All_Content') writer.save()
全站熱搜
留言列表