Application Requirements

In this lesson, we will look at the requirements of an application which makes computations on the data from a CSV file.

Imagine you’re working with some sales data and one task is to calculate a sum of orders for some products. Your shopping system is elementary, and instead of a database, you have CSV files with the order data. There’s one file per product.

For example, here are the book sales:

date coupon code price discount quantity
5-12-2018 10.0 0 2
5-12-2018 10.0 0 1
6-12-2018 Santa 10.0 0.25 1
7-12-2018 10.0 0 1

Each line shows a book sale on a specific date. For example on 5th Dec, there were three sales, 10$ each, and one person bought two books. On 6th Dec we had one sale with a coupon code.

The data is encoded as a CSV file: sales/book.csv:

5-12-2018;;10.0;0;2;
5-12-2018;;10.0;0;1;
6-12-2018;Santa;10.0;0.25;1;
7-12-2018;;10.0;0;1;

The application should read the data and then calculate the sum, in the above case we have the following code:

Get hands-on with 1200+ tech skills courses.