Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Java and sales report to create number of sales in one day
    text
    copied!<p>I have quite a bit of experience with Java, but have rarely had to work with any type of inventory management systems, sales reports, and that kind of thing. I'm working on a project where I have an excel report file of sales for the past year. I can read this and find the information I need just fine, but I can't figure out how to get the number of sales for a particular item (SKU) each day without using a bunch of nested for loops. I know there has to be an easier way, but I can't think of one at the moment.</p> <p>For example, there's a bunch of information on 30,000 items that have sold over the past year. I have created an array of 'Item' objects that pulls and sets string values for 'sku' and 'timestamp' (when the purchase was made).</p> <p>Now I have to cycle through this and check how many items were sold each day, but I'm not for sure what the best way of doing this is.</p> <p>My Item array could look like this:</p> <pre><code>//item[0] ; sku="AKD123"; timestamp="2012-02-01"; //item[1] ; sku="REN134"; timestamp="2012-02-01"; //item[2] ; sku="PIK383"; timestamp="2012-02-01"; //item[3] ; sku="REN134"; timestamp="2012-02-01"; </code></pre> <p>There are about a million other items in this array, but from this, you can see that AKD123 sold 1, REN134 sold 2, PIK383 sold 1. I'm not for sure how to get this output. There has to be some sort of array method that can help me sort this in to day figures, but that may cause another problem because if a particular sku sold 0 units on 2012-02-01 then it wouldn't show up on the excel report. I also don't know how many different skus there will be on a given report, so that's troubling me as well.</p> <p>Code would be fantastic, but even a recommendation on what I need to search for would be great. I feel like I should already know how to do this, but I'm lacking sleep and haven't been able to figure it out for the past 2 hours without VERY time consuming nested for loops, so I decided to turn to the community.</p> <p>Thanks guys.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload