Question: Create a Python 3 program that imports a CSV and uses a bubble sort to sort the list alphabetically by last name. Once the data

Create a Python 3 program that imports a CSV and uses a bubble sort to sort the list alphabetically by last name. Once the data is sorted using a bubble sort, print out the first and last 5 records. The only import used should be CSV. Use the following code sections when programming, variables and names can be changed:

with open("C:/Users/le/csv/employees.csv") as csvfile:

file = csv.reader(csvfile)

for row in file:

def man1(n, j):

tstor = n[j]

n[j] = n[j + 1]

n[j + 1] = tstor

number_of_elements = len(name)

for i in range(0, number_of_elements - 1):

for j in range(0, number_of_elements - 1):

if(name[j] > name[j + 1]):

man1(name, j)

man1(age, j)

The CSV file should appear like the following:

Paul,Roberts,555-912-5999,proberts@roadrunner.com,MIS,Tech Support Jason,Miller,555-241-1541,jmiller@roadrunner.com,Business,Accountant Megan,Doe,555-544-2222,mdoe@roadrunner.com,MIS,Helpdesk Michael,Johnson,555-681-8272,mjohnson@roadrunner.com,MIS,Tech Support Jean,Thompson,555-782-2851,jthompson@roadrunner.com,Business,HR

The output should print the first and last 5 records after sorting alphabetically by last name.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!