I am a little stuck here and need some advice for how best to solve my problem: I have a CSV file with a lot of sales data in it(402,000+ lines). When there are no sales for a certain product in a store, there is no data.
Therefore I want to find those periods where there are no sales for a product in a store > 3 days and add them to a watchlist(file/list).
The unique identifier is the SKU + storename combined. So for example the SKU+storename would be 801Whangarei PAK n SAVE. And its missing sales from the 5/03/2019 to 7/03/2019 and I would want that added to a list.
The data looks as below: Sales data file image
public static void main(String[] args) throws IOException {
String line;
String[] elements;
String storename;
String sku;
String date;
BufferedReader order_lines = new BufferedReader(new FileReader("order_lines_file.csv"));
int counter = 0;
while ((line = order_lines.readLine()) != null){
counter++;
elements = line.split(",");
date = elements[5].trim();
storename = elements[2].trim();
sku = elements[1].trim();
String key = storename + sku;
System.out.println(key);
}
System.out.println("End Of File Reached");
}
}
I have really only got as far as reading the file as I know I will just end up wasting a long time trying to figure this out.
Pseudocode would look something like this:
FOREACH (Unique( sku + storename) IN Sales data){
if((current date - next date) > 3 days){
list.add(dates between current date & next date )
}
else{ next date = current date
}
Thanks in advance for your help! Let me know if you need any more information.