merhaba arkadaşlar,
öncelikle iki excel içersindeki bazı sütünleri alt alta yazıp bir excelde birleştirdim.Birleştirdiğim excel ismi Yeni Birlestirilmis Dosya.xlsx tir.
şimdide ellimde var olan PM - Devam Eden Hizmetler Raporu.xlsx excel içersine yeni birleştirilmiş dosya içersindeki tum akışlar sheetini kopyalamak fakat aşağıda olduğu için hatta alıyorum.
import numpy as np
import pandas as pd
import openpyxl as xl
f1 = pd.read_excel(“file1.xlsx”, sheet_name=“TUM AKISLAR”)
f2 = pd.read_excel(“file2.xlsx”, sheet_name=“Devam Eden Akislar Raporu”)
robot = [“Infrastructure Type”, “Master Work Flow Number”, “Sub Work Flow Number”, “Contract Detail Number”,
“Order Customer Full Name”, “Location Customer Full Name”, “Maximo ID”, “Maximo Status”, “Status Date”,
“SubStatus Description”, “Tobecancel”, “Fiber Request ID”, “Maximo Start Date”, “Owner Group”, “Aski Nedeni”,
“Region”, “Order Type”, “Master Work Flow Start Date”, “Master Dur. Days”, “Master dur. Days A.”,
“Order Customer Code”, “Sub Work Flow Start Date”, “Year”, “Month”, “WF Duration (days)”,
“WF Duration Interval”,
“Sub Work Flow Name”, “Step Status Group”, “Suspend Reason”, “Offer Name”, “Project Manager”,
“Contract Customer Account Manager”, “Contract Customer Sales Sector Group”, “Step Name”,
“Assigned User Position”, “Assigned User Full Name”, “Step Start Time”, “Step Duration (days)”,
“StepDuration Interval”, “Location Customer Delivery City”, “Location Customer Delivery Address”,
“Siparis Durumu”, “BHM”, “Suspend - Sorumlu Ekip”, “Ekip Bilgisi”, “Vergi Numarası”, “Maximo Dur.Days”, “Hız”,
“Hizmet”, “SLA”]
emptor = [“Ürün Tipi”, “Master Work Flow Number”, “Sub Work Flow Number”, “Contract Detail Number”,
“Order Customer Full Name”, “Location Customer Full Name”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”,
“Order Type”,
“Master Work Flow Start Date”, “Ana Akış Bekleme Süresi”, “Ana Akış Bekleme Aralığı”, “Order Customer Code”,
“Sub Work Flow Start Date”, “YIL”, “Tarih”, “Akış Bekleme Süresi”, “Akış Bekleme Aralığı”,
“Sub Work Flow Name”,
“Step Status Group”, “Suspend Reason.”, “Offer Name”, “Order Customer Project Manager”,
“Contract Customer Account Manager”, “Sektör Bazlı”, “Step Name”, “Assigned User Position”,
“Assigned User Full Name”, “Step Start Time”, “Adım Bekleme Süresi”, “Adım Bekleme Aralığı”,
“Location Customer Delivery City”, “”, “”, “”, “”, “Suspend Ekip Bilgisi”, “Vergi Numarası”, “”, “Hız”,
“Hizmet”, “SLA”]
df1 = pd.DataFrame(f1, columns=robot)
df2 = pd.DataFrame(f2, columns=emptor)
df = pd.DataFrame(np.array([i for i in df1.values] + [i for i in df2.values]), columns=robot)
veya columns2. Hangisini isterseniz.
df.reset_index(inplace=True) # sayı eklemek için
df = df.rename(columns=dict(index=“No”)) # sayının başlık ismini yazmak
xlwriter = pd.ExcelWriter(“Yeni Birlestirilmis Dosya.xlsx”)
df.to_excel(xlwriter, sheet_name=“TUM AKISLAR”, index=False)
xlwriter.close()
path1 = “Yeni Birlestirilmis Dosya.xlsx”
path2 = “PM - Devam Eden Hizmetler Raporu.xlsx”
wb1 = xl.load_workbook(filename=path1)
ws1 = wb1.worksheets[0]
wb2 = xl.load_workbook(filename=path2)
ws2 = wb2.create_sheet(ws1.title)
for row in ws1:
for cell in row:
ws2[cell.coordinate].value = cell.value
wb2.save(path2)
##############Aldığım hatta#############
C:\Users\yakupe.conda\envs\Excel\python.exe C:/yakup/PythonNew/son.py
Traceback (most recent call last):
File “C:/yakup/PythonNew/son.py”, line 55, in
wb2 = xl.load_workbook(filename=path2)
File “C:\Users\yakupe.conda\envs\Excel\lib\site-packages\openpyxl\reader\excel.py”, line 315, in load_workbook
reader.read()
File “C:\Users\yakupe.conda\envs\Excel\lib\site-packages\openpyxl\reader\excel.py”, line 280, in read
self.read_worksheets()
File “C:\Users\yakupe.conda\envs\Excel\lib\site-packages\openpyxl\reader\excel.py”, line 266, in read_worksheets
pivot = TableDefinition.from_tree(tree)
File “C:\Users\yakupe.conda\envs\Excel\lib\site-packages\openpyxl\descriptors\serialisable.py”, line 83, in from_tree
obj = desc.from_tree(el)
File “C:\Users\yakupe.conda\envs\Excel\lib\site-packages\openpyxl\descriptors\sequence.py”, line 85, in from_tree
return [self.expected_type.from_tree(el) for el in node]
File “C:\Users\yakupe.conda\envs\Excel\lib\site-packages\openpyxl\descriptors\sequence.py”, line 85, in
return [self.expected_type.from_tree(el) for el in node]
File “C:\Users\yakupe.conda\envs\Excel\lib\site-packages\openpyxl\descriptors\serialisable.py”, line 103, in from_tree
return cls(**attrib)
File “C:\Users\yakupe.conda\envs\Excel\lib\site-packages\openpyxl\pivot\table.py”, line 601, in init
self.x = x
File “C:\Users\yakupe.conda\envs\Excel\lib\site-packages\openpyxl\descriptors\sequence.py”, line 25, in set
raise TypeError(“Value must be a sequence”)
TypeError: Value must be a sequence
Process finished with exit code 1