Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this assignment you will use the features of bash scripting. You are given a block file format and you need to convert it to
For this assignment you will use the features of bash scripting.
You are given a block file format and you need to convert it to a CSV format, and then sum some columns.
The format is as follows:
Each block represents row in the table
Each block starts with and ends with
Each column is represented as a comma separated pair on its own line within the block. For example "height, on its own line represents a column height, with a value of in that row.
The blocks do not have to contain the same columns. If a block has one column, and another block does not. The block lacking that column has an assumed value of for that column.
Example block:
name,Otus Redding
height,
name,Bill Darling
weight,
In the above example there are two rows, and columns. The first block has values in the column name and height, and the second block has values in name and weight.
height,name,weight
Otus Redding,
Bill Darling,
The above block would represent the table
Write a script called scriptsh that accepts parameters:
$ is the filename of the block format
$ is a regex pattern that is to meant to match column names
You script will take the block formatted file and convert it to a csv file, as shown above. The column names should be in alphabetical order. Add an additional column to the table called result which sums up all the values in columns that match $ in a given row.
For the example invocation:
scriptsh exampleTable.csv eight"
Should write stdout
height,name,weight,result
Otus Redding,
Bill Darling,
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started