Earn Higher Grades With Instant Assignment Help.Ask Question!

Python Programming
(5/5)

Write a program to filter table data An engineer often must review catalog or table data for available parts to determine whether available parts will satisfy the needs of a given project or design.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Spring 2020 Python Project

  1. Write a program to filter table data

An engineer often must review catalog or table data for available parts to determine whether available parts will satisfy the needs of a given project or design. However, there are usually many more possible parts than one can conveniently glance at all at once. Having some way of narrowing the available part data to more closely fit the project constraints can be useful.

The project is to read in some table data and then allow the user to apply limiting constraints to it and then be able to see which of the parts on the table still satisfy those constraints.

The file name for the Python project, when submitted, must be PythonProject.py.

Table

The table will be some sort of text table, like CylindricalRollerBearingData_01.txt that is available on CatCourses. It will have three header lines and the third will be the names and units for the data lines that follow. For that third row, all but the last tab-separated column will be a string with the title and units for the numerical data in the rows that follow. The last column corresponds to the part model number, which is will be string in the data rows that follow.

The project code should make no assumption about the header lines, other than what is specified above.

The rest of the table will have the data corresponding to the columns mentioned in the third header line above. There can be any number of data lines. All of the data will be numerical and should be treated as floating point numbers, except for the last column, which is the string representing the model number for that row's part.

The code should work for other tables with different header lines. It should work with the only change being the file name of the data file. Changes in the data file might include different numbers of columns, different column titles and units, etc. The only thing that can be assumed is that the third row will have the column header information and that all but the last column will be numerical data.

User Input

After reading in the table, the script will run in a loop that asks the user whether or not to add limits. Each limit will be for a particular table column (except for the last column) and will consist of a min and a max value for that column. The range of possible limits for the data and the current limit should be clear to the user. Add as many limits as the user wants, then print out the rows of the table that meet the limit requirements.

The python function raw_input() may be useful for getting input where it is okay for the user to simply hit Enter.

Output

The script output should have the following features:

  • The numerical values should have 2 digits to the right of the decimal

 

  • The output format should print in a neat format, with the output values' decimal points aligned for each output quantity. See the example output below for guidance. It may be useful to use the len() function when reading the headers, to ensure that the format used is wide enough to print them with some space to separate them from the adjacent
  • The user will be given the option to do another after each filtered table is
  • The script should run until the user elects to quit. One approach to this will be to define two continue-style variables, one to allow entry of limits and another to allow leaving the program overall.

Code Flexibility

As noted previously, the code should be written so that dealing with other tables with more or fewer columns requires no change to the code except for the new file name.

Some Hints

It may be useful to get going by deciding what sort of variable structure to use to store the table data once it has been read in. Keep in mind that any approach that defines col1, col2, col3, etc. will likely fail the flexibility requirement, since the code should be able to handle tables with 2 columns or 200 columns without changing the code. One can readily use lists of lists or dictionaries of lists to store the data.

It will be useful to go through the data and set the maximum and minimum values for each column, for display when the user enters limits.

To see if a given row meets the limit requirements, one approach is, for each row in the unfiltered data, loop through the columns and compare each value to the lower and upper limits. If each value is within the limits, then add that row to the filtered results.

Though it is not required, this may be a good opportunity to use functions to do various tasks. An example might be writing a function that takes the unfiltered data and the filter limits and returns the filtered data. Or, a function that takes the variable with the filtered data and prints it in a neat table.

Examples:

The following is an example run. Note that the results are in a tidy format with numbers in a straight column.

[email protected] /cygdrive/c/Users/brokow/UCM Classes/ME 021/2020 Spring Assignments

$ python -m PythonProject Current limits are:

d[mm]

D[mm]

B[mm] C[kN]

C0[kN]

Pu[kN]

Ref speed[r/min]

Lim speed[r/min]

min 15.00

35.00

11.00 12.50

10.20

1.22

8000.00

9500.00

max 40.00

90.00

33.00 129.00

120.00

15.30

22000.00

34000.00

There are currently 213 rows of data within these limits.

 

Alter limits (Y/N) ? y

d[mm] must be between 15.00 and 40.00

Enter new lower limit or [Enter] to keep 15.00: Enter new upper limit or [Enter] to keep 40.00: 20

D[mm] must be between 35.00 and 90.00

Enter new lower limit or [Enter] to keep 35.00: Enter new upper limit or [Enter] to keep 90.00:

B[mm] must be between 11.00 and 33.00

Enter new lower limit or [Enter] to keep 11.00: Enter new upper limit or [Enter] to keep 33.00:

C[kN] must be between 12.50 and 129.00

 

Enter new lower limit or [Enter] to keep 12.50: 30 Enter new upper limit or [Enter] to keep 129.00:

C0[kN] must be between 10.20 and 120.00

Enter new lower limit or [Enter] to keep 10.20:

Enter new upper limit or [Enter] to keep 120.00: Pu[kN] must be between 1.22 and 15.30

Enter new lower limit or [Enter] to keep 1.22:

Enter new upper limit or [Enter] to keep 15.30: Ref speed[r/min] must be between 8000.00 and 22000.00

Enter new lower limit or [Enter] to keep 8000.00:

Enter new upper limit or [Enter] to keep 22000.00: Lim speed[r/min] must be between 9500.00 and 34000.00

Enter new lower limit or [Enter] to keep 9500.00:

Enter new upper limit or [Enter] to keep 34000.00: Current limits are:

d[mm] D[mm] B[mm] C[kN]  C0[kN]  Pu[kN]  Ref speed[r/min]  Lim speed[r/min] min  15.00  35.00 11.00 30.00               10.20    1.22           8000.00           9500.00

max  20.00  90.00  33.00 129.00 120.00  15.30          22000.00          34000.00

There are currently 9 rows of data within these limits. Alter limits (Y/N) ? n

Data within chosen limits:

d[mm]

D[mm]

B[mm]

C[kN]

C0[kN]

Pu[kN]

Ref speed[r/min]

Lim speed[r/min]

Designation bearing

20.00

47.00

18.00

34.50

27.50

3.45

17000.00

19000.00

NJ 2204 ECP

20.00

47.00

18.00

34.50

27.50

3.45

17000.00

19000.00

NU 2204 ECP

20.00

52.00

15.00

35.50

26.00

3.25

15000.00

18000.00

N 304 ECP

20.00

52.00

15.00

35.50

26.00

3.25

15000.00

18000.00

NJ 304 ECP

20.00

52.00

15.00

35.50

26.00

3.25

15000.00

18000.00

NU 304 ECP

20.00

52.00

15.00

35.50

26.00

3.25

15000.00

18000.00

NUP 304 ECP

20.00

52.00

21.00

47.50

38.00

4.80

15000.00

18000.00

NJ 2304 ECP

20.00

52.00

21.00

47.50

38.00

4.80

15000.00

18000.00

NU 2304 ECP

20.00

52.00

21.00

47.50

38.00

4.80

15000.00

18000.00

NUP 2304 ECP

 

"Y" to do another, anything else to quit: y Current limits are:

d[mm]

D[mm]

B[mm] C[kN]

C0[kN]

Pu[kN]

Ref speed[r/min]

Lim speed[r/min]

min 15.00

35.00

11.00 30.00

10.20

1.22

8000.00

9500.00

max 20.00

90.00

33.00 129.00

120.00

15.30

22000.00

34000.00

There are currently 9 rows of data within these limits.

 

Alter limits (Y/N) ? y

d[mm] must be between 15.00 and 40.00

Enter new lower limit or [Enter] to keep 15.00:

Enter new upper limit or [Enter] to keep 20.00: D[mm] must be between 35.00 and 90.00

Enter new lower limit or [Enter] to keep 35.00:

Enter new upper limit or [Enter] to keep 90.00: B[mm] must be between 11.00 and 33.00

Enter new lower limit or [Enter] to keep 11.00:

Enter new upper limit or [Enter] to keep 33.00: C[kN] must be between 12.50 and 129.00

Enter new lower limit or [Enter] to keep 30.00:

Enter new upper limit or [Enter] to keep 129.00: C0[kN] must be between 10.20 and 120.00

Enter new lower limit or [Enter] to keep 10.20: 30

Enter new upper limit or [Enter] to keep 120.00: Pu[kN] must be between 1.22 and 15.30

Enter new lower limit or [Enter] to keep 1.22:

Enter new upper limit or [Enter] to keep 15.30: Ref speed[r/min] must be between 8000.00 and 22000.00

Enter new lower limit or [Enter] to keep 8000.00:

Enter new upper limit or [Enter] to keep 22000.00: Lim speed[r/min] must be between 9500.00 and 34000.00

Enter new lower limit or [Enter] to keep 9500.00:

Enter new upper limit or [Enter] to keep 34000.00: Current limits are:

d[mm] D[mm] B[mm] C[kN]  C0[kN]  Pu[kN]  Ref speed[r/min]  Lim speed[r/min] min  15.00  35.00 11.00 30.00               30.00    1.22           8000.00           9500.00

 

max  20.00  90.00  33.00 129.00 120.00  15.30          22000.00          34000.00

There are currently 3 rows of data within these limits. Alter limits (Y/N) ? n

Data within chosen limits:

d[mm]

D[mm]

B[mm]

C[kN]

C0[kN]

Pu[kN]

Ref speed[r/min]

Lim speed[r/min]

Designation bearing

20.00

52.00

21.00

47.50

38.00

4.80

15000.00

18000.00

NJ 2304 ECP

20.00

52.00

21.00

47.50

38.00

4.80

15000.00

18000.00

NU 2304 ECP

20.00

52.00

21.00

47.50

38.00

4.80

15000.00

18000.00

NUP 2304 ECP

 

"Y" to do another, anything else to quit: q

 

[email protected] /cygdrive/c/Users/brokow/UCM Classes/ME 021/2020 Spring Assignments

$ python -m PythonProject Current limits are:

d[mm] D[mm] B[mm] C[kN]  C0[kN]  Pu[kN]  Ref speed[r/min]  Lim speed[r/min] min  15.00  35.00 11.00 12.50               10.20    1.22           8000.00           9500.00

max  40.00  90.00  33.00 129.00 120.00  15.30          22000.00          34000.00

There are currently 213 rows of data within these limits.

 

Alter limits (Y/N) ? y

d[mm] must be between 15.00 and 40.00

Enter new lower limit or [Enter] to keep 15.00:

Enter new upper limit or [Enter] to keep 40.00: D[mm] must be between 35.00 and 90.00

Enter new lower limit or [Enter] to keep 35.00:

Enter new upper limit or [Enter] to keep 90.00: B[mm] must be between 11.00 and 33.00

Enter new lower limit or [Enter] to keep 11.00:

Enter new upper limit or [Enter] to keep 33.00: C[kN] must be between 12.50 and 129.00

Enter new lower limit or [Enter] to keep 12.50: 40

Enter new upper limit or [Enter] to keep 129.00: 70

C0[kN] must be between 10.20 and 120.00

Enter new lower limit or [Enter] to keep 10.20:

Enter new upper limit or [Enter] to keep 120.00: Pu[kN] must be between 1.22 and 15.30

Enter new lower limit or [Enter] to keep 1.22:

Enter new upper limit or [Enter] to keep 15.30: Ref speed[r/min] must be between 8000.00 and 22000.00

Enter new lower limit or [Enter] to keep 8000.00:

Enter new upper limit or [Enter] to keep 22000.00: Lim speed[r/min] must be between 9500.00 and 34000.00

Enter new lower limit or [Enter] to keep 9500.00: 17000

Enter new upper limit or [Enter] to keep 34000.00: Current limits are:

d[mm] D[mm] B[mm]  C[kN]  C0[kN]  Pu[kN]  Ref speed[r/min] Lim speed[r/min] min  15.00  35.00 11.00 40.00               10.20    1.22           8000.00          17000.00

max  40.00  90.00  33.00 70.00 120.00  15.30          22000.00          34000.00

There are currently 21 rows of data within these limits. Alter limits (Y/N) ? n

Data within chosen limits:

d[mm]

D[mm]

B[mm]

C[kN]

C0[kN]

Pu[kN]

Ref speed[r/min]

Lim speed[r/min]

Designation bearing

20.00

52.00

21.00

47.50

38.00

4.80

15000.00

18000.00

NJ 2304 ECP

20.00

52.00

21.00

47.50

38.00

4.80

15000.00

18000.00

NU 2304 ECP

20.00

52.00

21.00

47.50

38.00

4.80

15000.00

18000.00

NUP 2304 ECP

25.00

62.00

17.00

46.50

36.50

4.55

12000.00

22000.00

NJ 305 ECML

25.00

62.00

17.00

46.50

36.50

4.55

12000.00

22000.00

NU 305 ECML

25.00

62.00

17.00

46.50

36.50

4.55

12000.00

22000.00

NUP 305 ECML

25.00

62.00

24.00

64.00

55.00

6.95

12000.00

22000.00

NJ 2305 ECML

25.00

62.00

24.00

64.00

55.00

6.95

12000.00

22000.00

NU 2305 ECML

25.00

62.00

24.00

64.00

55.00

6.95

12000.00

22000.00

NUP 2305 ECML

30.00

62.00

16.00

44.00

36.50

4.50

13000.00

22000.00

NU 206 ECML

30.00

62.00

16.00

44.00

36.50

4.55

13000.00

22000.00

NJ 206 ECML

30.00

62.00

16.00

44.00

36.50

4.55

13000.00

22000.00

NUP 206 ECML

30.00

62.00

20.00

55.00

49.00

6.10

13000.00

22000.00

NU 2206 ECML

 

30.00

72.00

19.00

58.50

48.00

6.20

11000.00

19000.00

NJ 306 ECML

30.00

72.00

19.00

58.50

48.00

6.20

11000.00

19000.00

NU 306 ECML

30.00

72.00

19.00

58.50

48.00

6.20

11000.00

19000.00

NUP 306 ECML

35.00

72.00

17.00

56.00

48.00

6.10

11000.00

18000.00

NJ 207 ECML

35.00

72.00

17.00

56.00

48.00

6.10

11000.00

18000.00

NU 207 ECML

35.00

72.00

17.00

56.00

48.00

6.10

11000.00

18000.00

NUP 207 ECML

35.00

72.00

23.00

69.50

63.00

8.15

11000.00

18000.00

NJ 2207 ECML

35.00

72.00

23.00

69.50

63.00

8.15

11000.00

18000.00

NU 2207 ECML

 

"Y" to do another, anything else to quit: y Current limits are:

d[mm]

D[mm]

B[mm]

C[kN]

C0[kN]

Pu[kN]

Ref speed[r/min]

Lim speed[r/min]

min 15.00

35.00

11.00

40.00

10.20

1.22

8000.00

17000.00

max 40.00

90.00

33.00

70.00

120.00

15.30

22000.00

34000.00

There are currently 21 rows of data within these limits.

 

Alter limits (Y/N) ? y

d[mm] must be between 15.00 and 40.00

Enter new lower limit or [Enter] to keep 15.00:

Enter new upper limit or [Enter] to keep 40.00: D[mm] must be between 35.00 and 90.00

Enter new lower limit or [Enter] to keep 35.00:

Enter new upper limit or [Enter] to keep 90.00: B[mm] must be between 11.00 and 33.00

Enter new lower limit or [Enter] to keep 11.00:

Enter new upper limit or [Enter] to keep 33.00: C[kN] must be between 12.50 and 129.00

Enter new lower limit or [Enter] to keep 40.00:

Enter new upper limit or [Enter] to keep 70.00: C0[kN] must be between 10.20 and 120.00

Enter new lower limit or [Enter] to keep 10.20: 45 Enter new upper limit or [Enter] to keep 120.00:

Pu[kN] must be between 1.22 and 15.30

Enter new lower limit or [Enter] to keep 1.22:

Enter new upper limit or [Enter] to keep 15.30: Ref speed[r/min] must be between 8000.00 and 22000.00

Enter new lower limit or [Enter] to keep 8000.00:

Enter new upper limit or [Enter] to keep 22000.00: Lim speed[r/min] must be between 9500.00 and 34000.00

Enter new lower limit or [Enter] to keep 17000.00:

Enter new upper limit or [Enter] to keep 34000.00: Current limits are:

d[mm] D[mm] B[mm]  C[kN]  C0[kN]  Pu[kN]  Ref speed[r/min] Lim speed[r/min] min  15.00  35.00 11.00 40.00               45.00    1.22           8000.00          17000.00

max  40.00  90.00  33.00 70.00 120.00  15.30          22000.00          34000.00

There are currently 12 rows of data within these limits. Alter limits (Y/N) ? n

Data within chosen limits:

d[mm]

D[mm]

B[mm]

C[kN]

C0[kN]

Pu[kN]

Ref speed[r/min]

Lim speed[r/min]

Designation bearing

25.00

62.00

24.00

64.00

55.00

6.95

12000.00

22000.00

NJ 2305 ECML

25.00

62.00

24.00

64.00

55.00

6.95

12000.00

22000.00

NU 2305 ECML

25.00

62.00

24.00

64.00

55.00

6.95

12000.00

22000.00

NUP 2305 ECML

30.00

62.00

20.00

55.00

49.00

6.10

13000.00

22000.00

NU 2206 ECML

30.00

72.00

19.00

58.50

48.00

6.20

11000.00

19000.00

NJ 306 ECML

30.00

72.00

19.00

58.50

48.00

6.20

11000.00

19000.00

NU 306 ECML

30.00

72.00

19.00

58.50

48.00

6.20

11000.00

19000.00

NUP 306 ECML

35.00

72.00

17.00

56.00

48.00

6.10

11000.00

18000.00

NJ 207 ECML

35.00

72.00

17.00

56.00

48.00

6.10

11000.00

18000.00

NU 207 ECML

35.00

72.00

17.00

56.00

48.00

6.10

11000.00

18000.00

NUP 207 ECML

35.00

72.00

23.00

69.50

63.00

8.15

11000.00

18000.00

NJ 2207 ECML

35.00

72.00

23.00

69.50

63.00

8.15

11000.00

18000.00

NU 2207 ECML

 

"Y" to do another, anything else to quit: q

Attachments:
(5/5)

Expert's Answer

10 Times Downloaded

Related Questions

CSI 1420 Introduction to C Programming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu

The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

10 Times Downloads

Ask This Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
603 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
727 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
984 Answers Hire Me