Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Python, please help with my assignment. roster extended. csv newroster.csv Write a program that asks the user for the name of a file

Please use Python, please help with my assignment.

image text in transcribed

roster extended. csv

image text in transcribed

newroster.csvimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Write a program that asks the user for the name of a file (assume that the user will give you a .csv file formatted similar to roster extended.csv B and newroster.csv b). The user could give you ANY file name, so make sure your program is flexible enough to take in any.csv file with the roster format. The goal of your program is to save the given roster AND additional user-input roster entries to a FORMATTED TEXT (.txt) file. Do not modify the original file.csv file. The user should interact with the program in the following way: X 67 Ivy first last age Anna Barbara Catherine Do Eric Frederick Gabriel Hernandez Joo Kelly Marks Nancy Owens Patricia Qin Roderick Stevenson Tracy Umfreville Victoria Wolfeschle Lucy Xi Yolanda Zachary occupation height 35 nurse 45 physicist 28 teacher 55 surgeon 31 engineer 21 student 60 immunolog 36 dental assi: 51 bus driver 42 audiologist 38 data analys 49 professor 58 secretary weight sedentary moderate active 63 129 x 65 135 X 65 140 150 x 62 126 x 64 132 X 170 x 59 110 x 66 160 x 67 156 x 68 158 69 161 70 164 x 68 first last age Alvin Zacchaeus Bobby Yap Corinne Xuan Daphne Waters Edward Viola Ferdinand Ueng occupation height 65 physician 54 trainer 87 biochemist 23 receptionis 43 statistician 39 data scienti weight sedentary moderate active 65 139 x 66 140 x 68 166 62 110 x 64 145 x 72 202 X Hello. Please enter a roster file: roster_extended.csv There are 13 names in this file. Would you like to enter additional names? (Y/N) Y How many more names? 2 Person 1 ----- First Name: Spongebob Last Name: Squarepants Age: 33 Occupation: fry cook Height (in inches): 50 Weight (in pounds): 100 Lifestyle (1-sedentary, 2-moderate, 3-active): 3 Person 2 ----- First Name: Patrick Last Name: Star Age: 35 Occupation: unemployed Height (in inches): 50 Weight (in pounds): 180 Lifestyle (1-sedentary, 2-moderate, 3-active): 3 ----- Save new roster file as: roster_extended2.txt File saved! Hello. Please enter a roster file: roster_extended.csv There are 13 names in this file. Would you like to enter additional names? (Y/N) N Save new roster file as: roster_extended.txt File saved! ---- Hello. Please enter a roster file: roster_extend.csv ERROR, FILE DOES NOT EXIST. Please enter a roster file: roster_extended.csv There are 13 names in this file. Would you like to enter additional names? (Y/N) Y How many more names? 1 Person 1 ----- First Name: Superlongname thatyouwillhavetoconsider Last Name: Alsodontassume thattherosterfilewillhavelongnames Age: 99 Occupation: extremelyiongoccupationtitle Height (in inches): 76 Weight (in pounds): 325 Lifestyle (1-sedentary, 2-moderate, 3-active): 3 Save new roster file as: roster_extended.txt File saved! Note in example 2, the user might enter the wrong file name. You only need to re-prompt for the correct file name once. Thereafter, you may assume that the user will follow the rules and enter values that make sense (e.g. correct 2nd- attempt file name, numeric value for height and weight, 1-3 for lifestyle, etc.) When saving the text file there should be a header line (similar to the roster extended.csv file but with a different format). However, the number of spaces left for the first name, last name, and occupation will vary depending on the longest first name, last name, and occupation in your roster. Include all names from the csv roster and from the user input. The spacing in your newly written .txt file should be as follows: X spaces for the first name (where x is the number of characters in the longest first name or 9 if all names are less than 9 characters in length), y spaces for the last name (where y is the number of characters in the longest last name or 8 if all names are less than 8 characters in length), . 3 spaces for age, z spaces for occupation (where z is the number of characters in the longest occupation or 10 if all occupations are less than 10 characters in length), 5 spaces for height in feet and inches (62 should be 5'2") 3 spaces for weight, and 9 spaces for activity level AND one space in between each element Note, that this new roster file has three columns (sedentary, moderate, active), which you will need to combine into one "Lifestyle" column when you create your text file. Text should be right-aligned. After running the program, the start and end of your text file should look like... Occupation nurse Ht Wt Lifestyle 5'3" 129 moderate ........ First Name LastName Age Anna Barbara 35 (more names). Eric Wolfeschlegelsteinhausenbergerdorff 38 Lucy Xi 49 Yolanda Zachary 58 data analyst 5'8" 158 moderate professor 5'9" 161 moderate secretary 5'10" 164 sedentary Keep in mind roster extended.csv D is only an example, so a long name like "Wolfeschlegelsteinhausenbergerdorff" might NOT be a name in the roster file. In addition, the user may add an even longer name to the file. Make sure your program is able to adjust accordingly. Write a program that asks the user for the name of a file (assume that the user will give you a .csv file formatted similar to roster extended.csv B and newroster.csv b). The user could give you ANY file name, so make sure your program is flexible enough to take in any.csv file with the roster format. The goal of your program is to save the given roster AND additional user-input roster entries to a FORMATTED TEXT (.txt) file. Do not modify the original file.csv file. The user should interact with the program in the following way: X 67 Ivy first last age Anna Barbara Catherine Do Eric Frederick Gabriel Hernandez Joo Kelly Marks Nancy Owens Patricia Qin Roderick Stevenson Tracy Umfreville Victoria Wolfeschle Lucy Xi Yolanda Zachary occupation height 35 nurse 45 physicist 28 teacher 55 surgeon 31 engineer 21 student 60 immunolog 36 dental assi: 51 bus driver 42 audiologist 38 data analys 49 professor 58 secretary weight sedentary moderate active 63 129 x 65 135 X 65 140 150 x 62 126 x 64 132 X 170 x 59 110 x 66 160 x 67 156 x 68 158 69 161 70 164 x 68 first last age Alvin Zacchaeus Bobby Yap Corinne Xuan Daphne Waters Edward Viola Ferdinand Ueng occupation height 65 physician 54 trainer 87 biochemist 23 receptionis 43 statistician 39 data scienti weight sedentary moderate active 65 139 x 66 140 x 68 166 62 110 x 64 145 x 72 202 X Hello. Please enter a roster file: roster_extended.csv There are 13 names in this file. Would you like to enter additional names? (Y/N) Y How many more names? 2 Person 1 ----- First Name: Spongebob Last Name: Squarepants Age: 33 Occupation: fry cook Height (in inches): 50 Weight (in pounds): 100 Lifestyle (1-sedentary, 2-moderate, 3-active): 3 Person 2 ----- First Name: Patrick Last Name: Star Age: 35 Occupation: unemployed Height (in inches): 50 Weight (in pounds): 180 Lifestyle (1-sedentary, 2-moderate, 3-active): 3 ----- Save new roster file as: roster_extended2.txt File saved! Hello. Please enter a roster file: roster_extended.csv There are 13 names in this file. Would you like to enter additional names? (Y/N) N Save new roster file as: roster_extended.txt File saved! ---- Hello. Please enter a roster file: roster_extend.csv ERROR, FILE DOES NOT EXIST. Please enter a roster file: roster_extended.csv There are 13 names in this file. Would you like to enter additional names? (Y/N) Y How many more names? 1 Person 1 ----- First Name: Superlongname thatyouwillhavetoconsider Last Name: Alsodontassume thattherosterfilewillhavelongnames Age: 99 Occupation: extremelyiongoccupationtitle Height (in inches): 76 Weight (in pounds): 325 Lifestyle (1-sedentary, 2-moderate, 3-active): 3 Save new roster file as: roster_extended.txt File saved! Note in example 2, the user might enter the wrong file name. You only need to re-prompt for the correct file name once. Thereafter, you may assume that the user will follow the rules and enter values that make sense (e.g. correct 2nd- attempt file name, numeric value for height and weight, 1-3 for lifestyle, etc.) When saving the text file there should be a header line (similar to the roster extended.csv file but with a different format). However, the number of spaces left for the first name, last name, and occupation will vary depending on the longest first name, last name, and occupation in your roster. Include all names from the csv roster and from the user input. The spacing in your newly written .txt file should be as follows: X spaces for the first name (where x is the number of characters in the longest first name or 9 if all names are less than 9 characters in length), y spaces for the last name (where y is the number of characters in the longest last name or 8 if all names are less than 8 characters in length), . 3 spaces for age, z spaces for occupation (where z is the number of characters in the longest occupation or 10 if all occupations are less than 10 characters in length), 5 spaces for height in feet and inches (62 should be 5'2") 3 spaces for weight, and 9 spaces for activity level AND one space in between each element Note, that this new roster file has three columns (sedentary, moderate, active), which you will need to combine into one "Lifestyle" column when you create your text file. Text should be right-aligned. After running the program, the start and end of your text file should look like... Occupation nurse Ht Wt Lifestyle 5'3" 129 moderate ........ First Name LastName Age Anna Barbara 35 (more names). Eric Wolfeschlegelsteinhausenbergerdorff 38 Lucy Xi 49 Yolanda Zachary 58 data analyst 5'8" 158 moderate professor 5'9" 161 moderate secretary 5'10" 164 sedentary Keep in mind roster extended.csv D is only an example, so a long name like "Wolfeschlegelsteinhausenbergerdorff" might NOT be a name in the roster file. In addition, the user may add an even longer name to the file. Make sure your program is able to adjust accordingly

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

Intelligent Image Databases Towards Advanced Image Retrieval

Authors: Yihong Gong

1st Edition

1461375037, 978-1461375036

More Books

Students also viewed these Databases questions

Question

Presentation Aids Practicing Your Speech?

Answered: 1 week ago