I’m going to start getting a csv file every week from which I need to create a report. I really need to script this but need some help!
Files shared using GitHub.
Fruits.csv has many products (object) where “[;” is a unique ID for the object name. The square bracket followed by the unique ID number and a semi-colon always follows a friendly name for the product e.g. mybananas [99;]. Following this first semi-colon may or may not be location names of the product that for this report are irrelevant. Need the ability to process only those products (via unique IDs) that are provided in in a filed called process_these.txt
Many time events (time). Each object has an entry for each time. This point in time is what the values from each object need to be grouped by.
Each object has a quantity for each time recorded (quantity).
Each object has two other pieces of information in d1 and d2 (d1, d2).
From this I need to create an object (maybe a CSV) with the following
For each “time”:
Process only those “objects” with unique IDs listed in process_these.txt.
Export a CSV with the following headers: Time,sumquantity,sumd1,averaged2
E.g. taking the data from time 01/01/2017 01:02:01 I would expect to see the following:
$timeout; every “time” entry e.g. 01/01/2017 01:02:01
$sumquantity; sum of “quantity” from all objects at that time e.g. 11
$sumd1; sum of “d1” from all objects at that time e.g. 20
$averaged2; average of “d2” from all objects at that time e.g. 5
Example Csv-out file:
Time,sumquantity,sumd1,averaged2
01/01/2017 01:01:01,2,20,7
01/01/2017 01:02:01,11,20,5