Combine Driver Route Tables into a Single Workbook¶
After you have optimized each driver’s route in Circuit, you will need to combine the optimized routes back into a single workbook to create the driver manifest. This combining task can be done by using the combine_route_tables
tool.
This tool replaces the manual task of copying each driver’s optimized route into a single workbook. It will combine all the optimized routes into a single workbook, with each driver’s route on a separate sheet.
(After this step you’ll pass the combined workbook to format_combined_routes
to create the printable manifest. See Format Manifests.)
Note
create_manifests
wraps this tool and format_combined_routes
into one tool. You can still use them if you wish, but you can instead use create_manifests
. See Create Printable Manifests from Downloaded Optimized Routes and Format Manifests.
Python API documentation at bfb_delivery.api.public.combine_route_tables()
.
CLI documentation at CLI.
Usage¶
You pass the directory containing the optimized route tables to combine_route_tables
, along with any other optional arguments, and it will create a single workbook file with all the optimized routes combined. The tool then returns the filepath to that file so you can continue to work with it as needed (formatting and printing, see Format Manifests).
Note
The route CSVs from Circuit should be in a single directory, with no other CSVs in it.
Note
This will change the “Product Type” column name, per Circuit API, back to “Box Type” per food bank staff preferences.
You must at least pass input_dir
to combine_route_tables
.
In Python:
from bfb_delivery import combine_route_tables
combine_route_tables(input_dir="path/to/input/")
With CLI:
combine_route_tables --input_dir path/to/input/
The function will return the filepath to the combined file, which you can then open and review before you pass to format_combined_routes
to format the manifests for printing (see Format Manifests). If you’re using the CLI, the filepath will be printed to the console.
Note
You can pass the combine_route_tables
ouput to format_combined_routes
without reviewing the combined file first. We’re going to soon wrap these two steps into a single tool. But, for now, you need to run them separately.
Optional arguments¶
You can specify a few things about the combined workbook. Use –help to see all the optional arguments in the CLI.
combine_route_tables --help
Output directory¶
Use the optional argument output_dir
to specify the directory where the workbook file will be saved.
In Python:
combine_route_tables(input_dir="path/to/input/", output_dir="path/to/output_dir/")
With CLI:
combine_route_tables --input_dir path/to/input/ --output_dir path/to/output_dir/
Output filename¶
Choose the filename with output_name
. The default filename will be combined_routes_{today's date}.xlsx
(e.g., combined_routes_19991231.xlsx
). But, you can pass a preferred name that will be used instead.
In Python:
combine_route_tables(input_dir="path/to/input/", output_name="all_routes.xlsx")
With CLI:
combine_route_tables --input_dir path/to/input/ --output_name all_routes.xlsx
See Also¶
Create Printable Manifests from Downloaded Optimized Routes