In the lecture of Week-7 we introduced two new shell programming concepts - shell functions and hereis documents, that enabled us to transform simple CSV textual data into an HTML file suitable for viewing in a web-browser.
Our Task, here, is to reproduce the cssubmit.html file (into a different HTML) using the new shell features of shell functions and hereis documents.
Our sample solution for this Task
was developed in the recorded video of Week-7.
plotcssubmit.sh
(which will probably download when you click on the link)
employs a number of new (and common) techniques -
The result of displaying our HTML output in a web-browser:
Historically,
the maximum fuel price at most petrol stations has been seen on Tuesdays,
it steadily drops until the following Monday,
and then jumps up again the following day.
Of course, wise customers anticipate this cycle,
and try to purchase their fuel on Mondays.
....
Recently, it has been observed that the lowest price point is now on Tuesdays,
not Mondays.
Does the historical data support this observation?
Our sample solution to solve this Task is very similar to that of Task #1. We develop a shellscript to accumulate all four months of data, and then extract the specific rows, and then fields, that we want. Depending on how general we wish our shellscript to be, we may perform these commands either at the beginning of the whole script, or within the shell function that converts and generates the data rows:
plotfuel1.sh (which will probably download when you click on the link) employs the following methods -
The result of displaying our HTML output in a web-browser is:
Our plot clearly shows that prices have dropped this year, and that they appear to fluctuate regularly, but what about the observation that the lowest price point has moved from Mondays to Tuesdays?
If viewing the plot in your browser, hover your mouse over each lowest price. You'll see the first is on day 6, the next on day 13, ... all 7 days apart. But we notice that the low prices on days and 34 and 35 were the same - the shift from Monday to Tuesday!
Does your Line Chart show that the lowest price, each week, has shifted from a Monday to a Tuesday?
Our sample solution to solve this Task is very similar to that of Task #2. From Task #2 we have observed that the day of the lowest price 'shifted' between days 34 and 35. So we need to plot the data for January and February on the same chart.
plotfuel2.sh (which will probably download when you click on the link) is very similar to fuelwatch1.sh, but the shell function to collate the data now needs to deal with two files, and merge their data into data rows suitable for a Google Line Chart with two plots on the chart:
The result of displaying our HTML output in a web-browser is:
Our plot clearly shows that prices for both months have a regular cycle but, unless we have a calendar handy, just joining the data on the day of the month (1,2,3...) doesn't clearly show the shift from Monday to Tuesday.
Still to come - 🌶🌶 we need a better solution in which the X-axis is labelled with (repeating) days of the week, (Sun, Mon, Tue,....).