Untitled
klasa Table - za poredjenje dve excel tabele (gruba osnova)unknown
plain_text
4 years ago
2.9 kB
6
Indexable
class Table:
def __init__(self):
self.data = []
self.sheet = []
self.flights = []
self.data_list_of_sets=[]
self.namedflight=[]
self.x=[]
#self.workbook="Airport.xlsx"
self.no=0
self.date = "1.4.2022"
self.flight_type='NN'
self.flight_sub_type='NN'
self.flight='NN'
self.destination='NN'
self.ttl_guests=0
self.inf=0
self.transfer=0
self.id00=0
self.dhc=0
self.ttl_pax_for_charge=0
self.registration='NN'
self.ac_type='NN'
self.umnr=0
self.loc=0
def ucitajTabelu(self):
workbook = openpyxl.load_workbook(input("Unesi ime tabele: "))#(input("Unesi ime tabele: ")) ili ('Airport.xlsx')
sheet = workbook.active
print(workbook.active)
first_row = [] # The row where we stock the name of the column
for col in range(1, sheet.max_column+1):
first_row.append(sheet.cell(row=1, column=col).value)
data =[]
for row in range(2, sheet.max_row+1):
elm = {}
for col in range(1, sheet.max_column+1):
elm[first_row[col-1]]=sheet.cell(row=row,column=col).value
data.append(elm)
print (data) #radi ali izbacila sam
flights=[]
a=4
for row in sheet.iter_rows(1, sheet.max_row):
flights.append(row[a].value)
print('\n', "first colimn and fligt colimn values: ",flights)
print ("Tabela {workbook.active} je ucitana")
return data
"""
try:
return data
#return self.no , ' ' , self.date , ' ' , self.flight_type , ' ' , self.flight_sub_type , ' ' , self.flight , ' ' , self.destination , ' ' , self.ttl_guests , ' ' , self.inf , ' ' , self.transfer , ' ' , self.id00 , ' ' , self.dhc , ' ' , self.ttl_pax_for_charge , ' ' , self.registration , ' ' , self.ac_type , ' ' , self.umnr , ' ' , self.loc
print("prosao je try")
except Exception as e:
print(e)
return None
# return f"Netacno unet naziv fajla ili fajl ne postoji na datoj putanji"
def __str__(self):
return f"{self.no} , ' ' , {self.date} , ' ' , {self.flight_type} , ' ' , {self.flight_sub_type} , ' ' , {self.flight} , ' ' , {self.destination} , ' ' , {self.ttl_guests} , ' ' , {self.inf} , ' ' , {self.transfer} , ' ' , {self.id00} , ' ' , {self.dhc} , ' ' , {self.ttl_pax_for_charge} , ' ' , {self.registration} , ' ' , {self.ac_type} , ' ' , {self.umnr} , ' ' , {self.loc}"
"""
t1=Table()
t2=Table()
t1.ucitajTabelu()
t2=Table.ucitajTabelu("Carrier.xlsx")
print(t1)
print("")
print(t2)Editor is loading...