Question: Using Python: The specific tasks include: processing a pipe delimited file into a list (array) Formatting the output of string lists to custom column widths
Using Python:

The specific tasks include: processing a pipe delimited file into a list (array) Formatting the output of string lists to custom column widths String manipulation using string slicing Use of the find method. We will be using the file: AutoPipe.csv The submission for this lesson will be the Python Code, properly formatted with indents that Code 1. Reads the Pipe delimited file and displays it in tabbed columns Code 2. Reads the Pipe delimited file, splits the last column into make and model, then displays the make, model, and year using custom column widths. Code 3. Reads the Pipe | delimited file, adds up all of the MPG values and prints out a statement telling the Average MPG of all the included Autos AutoPipe.csv file: mpglcylindersldisplacementl horsepowerlweightlaccelerationlyearlorigin name 1818130711301350411217011Ichevrolet chevelle malibu 5181350116513693111.517011 lbuick skylark 320 181813181501343611117011 lplymouth satellite 16181304115013433112170111ame rebel sst 17181302114013449110.517011lford torino Started Code: open("c:/tmp/AutoPipe.csv) formatter - "%-5s %-5s %-5s %-5s %-5s %-5s %-5s %-5s %-5s" #cannot convert to csv because it's pipe delimited contents f.readlines() for 1 in contents: a,b,c,d,e,f, g, h , i 1.split("! ") #splitting at the pipe j : Aeplace(" ",""). split("!") #removing char return (new line) with replace print (formatter % (a,b,c,d,e,f,g,h,i.replace(" ","")))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
