-2

I’m needing to compare current day and previous day sales reports to find if there has been any sales removed. The new report would have more lines so the columns wouldn’t match up side by side on a spread sheet. How can I do like a mass comparison to find out if there have been names/sales removed

  • If you sorted in date order then everything would line up, enabling you to spot missing lines… but more worryingly, what kind of accounting system lets people delete sales rather than reversing them with a valid paper-trail? That sounds like a recipe for disaster. – Tetsujin Aug 13 '23 at 10:09
  • 1
    What kind of an answer are you seeking? Formula that returns missing values? A script? What have you tried? Any issues that we need to know about? Why all the tags? What does this have to do with Apple? MacBook? Applescript? – Blind Spots Aug 13 '23 at 17:43

1 Answers1

0

Solution

You can solve this problem by running a very simple python script.

Save this code as a python file and run it in the same folder as the sales reports you have compiled and it will output all the missing entries if any exist.

Make sure to insert the right names for you sales files:)

previous_report_file = 'previous_report.csv'

current_report_file = 'current_report.csv'

def read_sales_report(file_path):
    sales_data = {}
    with open(file_path, 'r') as file:
       for line in file:
           name, sales = line.strip().split(',')
           sales_data[name] = float(sales)
    return sales_data

def compare_sales_reports(previous_report, current_report):
    previous_data = read_sales_report(previous_report)
    current_data = read_sales_report(current_report)
    
missing_sales = []
for name in previous_data:
    if name not in current_data:
        missing_sales.append(name)

return missing_sales

previous_report_file = 'previous_report.csv'
current_report_file = 'current_report.csv'
missing_sales = compare_sales_reports(previous_report_file, current_report_file)

if len(missing_sales) == 0:
    print("No sales have been removed.")
else:
    print("Missing sales:")
    for sale in missing_sales:
        print(sale)

Note

To install python on mac simply run

homebrew install python