I'm still stuck in here, I'm trying to print a payslip. I want to refer to the employee_info.txt to get the time record according to the employee number. But my problem is the rate is in the employee_info and the days_work is in the time_record.txt and the main problem is it only prints one person or one month.
employee_info.txt is consists of employee no.,lastname,name,dapartment, rate per hour
201911007,James,Butt,Accounting,365;
201203008,Josephine,Darakjy,Marketing,365;
199710014,Art,Venere,Human Resources,750;
201612010,Lenna,Paprocki,Marketing,565;
201710017,Donette,Foller,Admin,450;
201701013,Simona,Morasca,Finance,450;
201011003,Mitsue,Tollner,Marketing,750;
201409015,Leota,Dilliard,Finance,365;
199512017,Sage,Wieser,MIS,750;
199708003,Kris,Marrier,Admin,750;
20011234, Robert, John, Finance, 120;
time_record.txt consist of employee no., month(in numbers), days worked
201911007,1,28;
201203008,1,28;
199710014,1,28;
201612010,1,28;
201710017,1,28;
201701013,1,28;
201011003,1,28;
201409015,1,28;
199512017,1,28;
199708003,1,28;
201911007,2,28;
201203008,2,28;
199710014,2,28;
201612010,2,28;
201710017,2,28;
201701013,2,28;
201011003,2,28;
201409015,2,28;
199512017,2,28;
199708003,2,28;
201911007,3,10;
201203008,3,27;
199710014,3,28;
201612010,3,19;
and my code is.
def printing(last_name,first_name,month,time_record_empno,emp_no,department,rate_per_day,days_work):
emp_no = [] #employee number as reference
first_name = []
last_name = []
department = []
rate_per_day = []
time_record_empno=[] # employee number
month=[]
days_work=[]
with open("employee_info.txt", 'r') as file:
for dl in file:
dl = dl.strip()
if len(dl) >= 1:
li = dl.split(",")
emp_no.append(li[0].strip())
first_name.append(li[1].strip())
last_name.append(li[2].strip())
department.append(li[3].strip())
rate_per_day.append(li[4].upper().rstrip(';'))
with open("time_record.txt", 'r') as files:
for dln in files:
dln = dln.strip()
if len(dln) >= 1:
lii = dln.split(",")
MR_empno.append(lii[0].strip())
month.append(lii[1].strip())
days_work.append(lii[2].rstrip(';'))
for mm, mr, ll, nn, emp, dep, rat, hr in zip(month, empno, last, name, mrem, depart, rates, hours):
files = open('payslip.txt', 'w')
print("*" * 160)
print(f"Payslip for the MONTH OF:{mm}")
print(f"Employee No.{mr}Employee Name:{ll}, {nn} ")
print(f"Department:{dep}")
print(f"Rate Per Day:{rat}No. of Hours Worked:{hr} ")
gross = int(rat)*int(hr)
print(f"Gross Pay:{gross}")
print("*" * 160)
Any suggestions to solve this? Thank you.