Instructions
Objective
Write a java assignment program to create hot dog consolidated hiring system.
Requirements and Specifications
Source Code
# U.R. Name
# AIST 2120: Programming Assignment 3 #! Python 3
# Submission
import re
import os
import sys
if __name__ == '__main__':
#Print greeting message
print("**** WEST VIRGINIA HOT DOGS CONSOLIDATED HIRING: CURRENT WEEK ****")
print()
# Check working directory
# Get the current working directory
cwd = os.getcwd()
print(f"The beginning CWD is {cwd}")
# Split to get the name of the last folder
last_folder = cwd.split('/')[-1]
if last_folder != 'Desktop':
#desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop')
desktop = os.path.join(os.path.join(os.environ['HG_USER']), 'Desktop')
print(f"\tTo ensure it resides in one with the HR input files,\n\tit is now {desktop}")
os.chdir(desktop)
print()
# Create a list to store the data
data = list()
sql_detected = list() # Inser SQL statements detected here
# Open firs file
with open('WVDogsAuburnHR.txt', 'r') as f:
# Read the lines, split them and insert into the list as sublists
lines = f.readlines()
for line in lines:
line = line.strip()
line = re.sub('\t+', '\t', line)
if line.startswith('SELECT') or line.startswith('DROP') or line.startswith('INSERT INTO'):
sql_detected.append(line)
else:
row = line.split('\t')
data.append(row)
with open('WVDogsChasHR.txt', 'r') as f:
# Read the lines, split them and insert into the list as sublists
lines = f.readlines()
for line in lines:
line = line.strip()
line = re.sub('\t+', '\t', line)
if line.startswith('SELECT') or line.startswith('DROP') or line.startswith('INSERT INTO'):
sql_detected.append(line)
else:
row = line.split('\t')
data.append(row)
if len(data) > 0:
print("All hiring files successfully opened. Beginning processing.")
# Now, process data
for sql in sql_detected:
print("==> SQL Detected and Removed!")
print(f"\t{sql}")
print()
# No, sort the data by name
data = sorted(data, key = lambda x: x[0])
# Finally, write to file
with open('WVDogsConsolidatedHiring.txt', 'w+') as fout:
# Write header
fout.write("{:<20s} {:>25s} {:>35s}\n".format("Employee Name", "Job Title", "Salary or Other Compensation"))
fout.write("{:<20s} {:>25s} {:>35s}\n".format("-------------", "---------", "----------------------------"))
for row in data:
fout.write("{:<20s} {:>25s} {:>35s}\n".format(row[0], row[1], row[2]))
print("Both hiring files have been copied to the consolidated file. Commencing data verification")
print()
# Now, for error check, re-open the output file and print it
with open('WVDogsConsolidatedHiring.txt', 'r') as fin:
lines = fin.readlines()
for line in lines:
line = line.strip()
print(line)
print()
print("All files are closed. WVDogsConsolidatedHiring.txt is ready for processing.")
print()
print("\t\t---------- HIRING REPORT COMPLETE ----------")
print()
else:
print("Hiring files could not be opened. Please check directory.")
print("Press ENTER to exit")
input()
sys.exit(0)
Similar Samples
Explore our expertise with a curated selection of programming homework samples. From introductory exercises to advanced projects, our samples showcase diverse languages and concepts, illustrating our commitment to quality and proficiency. Whether you need assistance in Python, Java, or C++, our samples reflect our dedication to delivering clear, effective solutions.
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java