Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import csv import sys from datetime import datetime def read _ ssn _ eid _ mapping ( file _ path ) : ssn _ eid
import csv
import sys
from datetime import datetime
def readssneidmappingfilepath:
ssneidmap
with openfilepath, moder as file:
reader csvreaderfile
for row in reader:
ssn eid row
ssneidmapssn: eid
return ssneidmap
def processsdffilepath, ssneidmap, ppenddates:
ppdata
bwdata
with openfilepath, moder as file:
for line in file:
if line.startswith:
continue
if line.startswithX or line.startswithW:
employeetype PP if line.startswithX else BW
ssn line:strip
if EMS' in line and ssn: in ssneidmap:
eid ssneidmapssn:
columns floatx for x in line:split
if employeetype PP:
ppdata.append
eid, ppenddates 'Performances', sumcolumns:
else:
bwdata.extend
eid ppenddates 'Vacation Used Info', columns
eid ppenddates 'Shift Pay City', columns
eid ppenddates 'Shift Pay City', columns
eid ppenddatesST Overtime', columns columns
eid ppenddatesST Overtime', columns columns
eid ppenddates 'Docked Pay', columns
eid ppenddates 'Medical Used Info', columns
eid ppenddates 'Sick Used Info', columns
return ppdata, bwdata
def writecsvfilename, data:
with openfilename, modew newline as file:
writer csvwriterfile
writer.writerowEmployee ID 'End Date', 'Category', 'Hours'
for row in data:
row frow:f
writer.writerowrow
def main:
# Prompt for input values
sdffile inputEnter the path to the SDF file:
emsfile inputEnter the path to the EMS file:
ppenddate inputEnter the first PP end date YYYYMMDD:
ppenddate inputEnter the second PP end date YYYYMMDD:
ppenddates ppenddate ppenddate
# Read SSN to EID mapping
ssneidmap readssneidmappingemsfile
# Process the SDF file
ppdata, bwdata processsdfsdffile, ssneidmap, ppenddates
# Write output files
ppfilename fEMSPPppenddatescsv
bwfilename fEMSBWppenddatescsv
writecsvppfilename, ppdata
writecsvbwfilename, bwdata
if namemain:
main
Input information:
Enter the path to the SDF file: F:SDFTranslationDPSDF
Enter the path to the EMS file: F:SDFTranslationDeptEMSEMSPersonNumberToLastcsv
Enter the first PP end date YYYYMMDD:
Enter the second PP end date YYYYMMDD:
The Python script provided aims to automate the translation of data from an input file format SDF to specific output formats for perperformance PP and regular employees BW The script follows detailed instructions regarding data extraction, transformation, and output formatting.
Need to amend the script with a print output folder results in the following format as dated "OutputfloderYYYYMMDD and must print the containing the two produced files titled
EMSPPPERPERFEMPLOYEES
EMSbwREGULAREMPLOYEES
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started