def main(): try: # parse command line arguments filename_catalog, filename_sales = _parse_command_line_parameters() # print(filename_catalog, filename_sales) # load sales data sales = load_sales_data(filename_sales) catalog_by_item_id = load_catalog_by_item_id(filename_catalog) # calculate and print summaries print_summary(sales) print_sales_amount_by_city(sales) print_sales_amount_by_category(sales, catalog_by_item_id) return 0 except Exception as e: print("Error: " + str(e)) raise
def main(): if len(sys.argv) < 4: print("Usage: {} <catalog-file.csv> <sales-file.csv> <output.db>".format(sys.argv[0])) return 2 # TODO: check if files exist and are readable catalog_by_item_id = load_catalog_by_item_id(sys.argv[1]) sales = load_sales_data(sys.argv[2]) db_filename = sys.argv[3] with sqlite3.connect(db_filename, isolation_level=None) as connection: print("Connection opened") create_tables(connection) print("Tables created") import_catalog_into_db(catalog_by_item_id, connection) print("Catalog imported") import_sales_into_db(sales, connection)
def main(): try: # parse command line arguments filename_catalog, filename_sales = _parse_command_line_parameters() print(filename_catalog, filename_sales) # load sales data sales = load_sales_data(filename_sales) catalog_by_item_id = load_catalog_by_item_id(filename_catalog) # calculate and print summaries print_summary(sales) print_sales_amount_by_city(sales) print_sales_amount_by_categories(sales, catalog_by_item_id) return 0 except Exception as e: print("Error: " + str(e)) raise
def main(): if len(sys.argv) < 4: print( "Usage: {} <catalog-file.csv> <sales-file.csv> <output.db>".format( sys.argv[0])) return 2 # TODO: check if files exist and are readable catalog_by_item_id = load_catalog_by_item_id(sys.argv[1]) sales = load_sales_data(sys.argv[2]) db_filename = sys.argv[3] with sqlite3.connect(db_filename, isolation_level=None) as connection: print("Connection opened") create_tables(connection) print("Tables created") import_catalog_into_db(catalog_by_item_id, connection) print("Catalog imported") import_sales_into_db(sales, connection)