Skip to content

dmertins/sales-data-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Development

System Modules

  • reader module
  • parser module
  • analyzer module
  • reporter module

Sales Data Analyzer

Sales Data Analyzer is a plain text file parser and data analyser, and a report generator system. It imports flat files, parses data from each file, analyses its data and generates a report output file for each input file.

The following sections describe the input file reader, the expected data format of the input files, the data analysis performed and the generated output report file.

Input File Reader

The application reads every new file with the .dat extension in $HOME/data/in/ path. Each file is parsed, according to an expected formatting layout, and its data is analyzed.

Input File Data

There are three possible types of data for each line, each with a specific format:

  1. salesman
  2. customer
  3. sales

Any lines containing invalid formatted data are ignored.

1. Salesman Data Format

A salesman data line starts with a 3-character id 001 and has the following layout:

001ç<cpf>ç<name>ç<salary>

Fields constraints:

  • cpf: a 11 character-wide numeric only field;
  • name: can contain any characters except 'ç'; must have length ≥ 1;
  • salary: can contain any digit in [0-9] and at most one '.' character; must have length ≥ 1;

2. Customer Data Format

A customer data line starts with a 3-character id 002 and has the following layout:

002ç<cnpj>ç<name>ç<business_area>

Fields constraints:

  • cnpj: a 14 character-wide numeric only field;
  • name: can contain any characters except 'ç'; must have length ≥ 1;
  • business_area: can contain any characters except 'ç'; must have length ≥ 1;

3. Sales Data Format

A sales data line starts with a 3-character id 003 and has the following layout:

003ç<sale_id>ç<item_list>ç<salesman_name>

Fields constraints:

  • sale_id: can contain any digit in [0-9]; must have length ≥ 1;

  • item_list: a comma-separated list, containing at least one item, with the following layout:

    [<item_id_1>-<item_quantity_1>-<item_price_1>,<item_id_2>-<item_quantity_2>-<item_price_2>,...,<item_id_n>-<item_quantity_n>-<item_price_n>]

    Fields constraints:

    • item_id: can contain any digit in [0-9]; must have length ≥ 1;
    • item_quantity: can contain any digit in [0-9]; must have length ≥ 1;
    • item_price: can contain any digit in [0-9] and at most one '.' character; must have length ≥ 1;
  • salesman_name: can contain any characters except 'ç'; must have length ≥ 1;

Data Analysis

The application summarizes for each input file the following data:

  • customers amount
  • salesmen amount
  • most expensive sale id
  • worst salesman name

Output File Generator

An output report file named <input_file_name>.done.dat is created in $HOME/data/out/ path for each input file analysed.

Report Data Format

The output report file has the following layout:

customers amount: <customers_amount>
salesmen amount: <salesmen_amount>
most expensive sale id: <most_expensive_sale_id>
worst salesman name: <worst_salesman_name>