Create Printable Manifests from Downloaded Optimized Routes¶
After you have optimized each driver’s route in Circuit, you will need to combine the optimized routes back into a single workbook of driver manifest sheets ready to print. You can do this with the create_manifests
tool.
This tool replaces the manual task of copying each driver’s optimized route into a single workbook, running an Excel macro, and finishing up with some manual steps. It will combine all the optimized routes into a single workbook, with each driver’s route on a separate sheet, and format the sheets into manifests ready to print.
Note
Uses the date of the front of each CSV name to set the manifest date field. I.e., each sheet should be named something like “07.17 Walt D”, and, e.g., this would set the manifest date field to “Date: 07.17”.
Note
This wraps the two other tools combine_route_tables
and format_combined_routes
into one tool. You can still use them if you wish, but you can instead use this tool. For instance, say you’ve found a bug when using create_manifests
. You could try running combine_route_tables
then passing its output to format_combined_routes
. For whichever of those steps fails you can revert to using your old method, but you can still ostensibly use the tool for the other piece that didn’t fail (e.g., combine_route_tables
ran fine, but format_combined_routes
threw an error, so you reverted to using the Excel macro and manually formatting). See Combine Driver Route Tables into a Single Workbook and Format Manifests.
Python API documentation at bfb_delivery.api.public.create_manifests()
.
CLI documentation at CLI.
Usage¶
You pass the directory containing the optimized route tables to create_manifests
, along with any other optional arguments, and it will create a single workbook file with all the optimized routes formatted and ready to print. The tool then returns the filepath to that file.
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 create_manifests
.
In Python:
from bfb_delivery import create_manifests
create_manifests(input_dir="path/to/input/")
With CLI:
create_manifests --input_dir path/to/input/
The function will return the filepath to the final manifest file. If you’re using the CLI, the filepath will print to the console.
Optional arguments¶
You can use optional arguments specify a few things about the manifest workbook. Use –help to see all the optional arguments in the CLI.
create_manifests --help
Output directory¶
Use the optional argument output_dir
to specify the directory where the workbook file will be saved.
In Python:
create_manifests(input_dir="path/to/input/", output_dir="path/to/output_dir/")
With CLI:
create_manifests --input_dir path/to/input/ --output_dir path/to/output_dir/
Output filename¶
Choose the filename with output_name
. The default filename will be final_manifests_{today's date}.xlsx
(e.g., final_manifests_19991231.xlsx
). But, you can pass a preferred name instead.
In Python:
create_manifests(input_dir="path/to/input/", output_name="all_routes.xlsx")
With CLI:
create_manifests --input_dir path/to/input/ --output_name all_routes.xlsx
Note
You can use both output_dir and output_name together to specify the directory and filename of the output workbook.
Supplying extra notes¶
Use the optional argument extra_notes_file
to specify a CSV file with extra notes to include in the manifest. The CSV file should have two columns: tag
and note
. The tag is the text (usually asterisked) that appears in the standard notes field for a delivery. The note is then added to the bottom of the manifest with the tag. For example:
tag,note
Cedarwood Apartments special instructions *,Please call the recipient when you arrive.
This file will put the note “Please call the recipient when you arrive.” at the bottom of the manifest (once) if any stops have a note that contains the text “Cedarwood Apartments special instructions *”.
If you don’t provide extra_notes_file
, the tool will use the constant notes in the codebase: bfb_delivery.lib.constants.ExtraNotes
(currently empty).
In Python:
create_manifests(
input_dir="path/to/combined_workbook.xlsx",
extra_notes_file="path/to/extra_notes.csv",
)
With CLI:
create_manifests --input_dir path/to/combined_workbook.xlsx --extra_notes_file path/to/extra_notes.csv
See Also¶
The Delivery-Planning Workflow