Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question #2 (10 marks) Create a Python program that takes a bady formatted data set and converts it into CSV. Details: . The data has

image text in transcribed

Question #2 (10 marks) Create a Python program that takes a bady formatted data set and converts it into CSV. Details: . The data has three felds which we will assume are always present: a number, a name (that contains no spaces), and a salary. The data may have mutiple spaces between the fields and all fields for the same row may be on different lines. Data set is here: 35000 Sanenthe 150000 10 Les 9900D Riley 53215 7Ashley 23424 IS Sheyanne 225aa0 9 Dave 35235 Put a mment at the top of the Pmon file called Lab5g2 with your name and student number. (0.5 mark) Put the data above into the Python code file using a triple quoted string. (05 mark) Use spl1t to divide up the messy data where fields are separated by spaces. (0.5 mark) Create individual lists for the ids, names, and salaries and print out each list. (1.5 marks) Output the data in CSV form: id, nane, aalary. (1 mark) . . . Create a new list where each element is a list representing a row in the CSV fle. Print this list. (1 mark) 8, or the person has a salary > 50000, (2 marks) Create and print a new list which includes only rows where the id >. 4 and id Output the original list in CSV form sorted by id ascending. (1 mark) .(2 marks) * Create and print a new list which for each row increases the salary by 50% if the length of the person's name is 3 characters or less or starts with . Bonus: Output the original list in CSV form sorted by salary descending. (1 mark) . Bonus: Create a function to output in CSV form and use it multiple times rather than duplicating code. (1 mark) Question #2 (10 marks) Create a Python program that takes a bady formatted data set and converts it into CSV. Details: . The data has three felds which we will assume are always present: a number, a name (that contains no spaces), and a salary. The data may have mutiple spaces between the fields and all fields for the same row may be on different lines. Data set is here: 35000 Sanenthe 150000 10 Les 9900D Riley 53215 7Ashley 23424 IS Sheyanne 225aa0 9 Dave 35235 Put a mment at the top of the Pmon file called Lab5g2 with your name and student number. (0.5 mark) Put the data above into the Python code file using a triple quoted string. (05 mark) Use spl1t to divide up the messy data where fields are separated by spaces. (0.5 mark) Create individual lists for the ids, names, and salaries and print out each list. (1.5 marks) Output the data in CSV form: id, nane, aalary. (1 mark) . . . Create a new list where each element is a list representing a row in the CSV fle. Print this list. (1 mark) 8, or the person has a salary > 50000, (2 marks) Create and print a new list which includes only rows where the id >. 4 and id Output the original list in CSV form sorted by id ascending. (1 mark) .(2 marks) * Create and print a new list which for each row increases the salary by 50% if the length of the person's name is 3 characters or less or starts with . Bonus: Output the original list in CSV form sorted by salary descending. (1 mark) . Bonus: Create a function to output in CSV form and use it multiple times rather than duplicating code. (1 mark)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions