Parse Canadian FSA information from Canada Post's Official Listing of Forward Sortation Areas
Python packages used:
- PyPDF2 - To parse information from the PDF
- re - To use regular expressions to focus on the FSAs
- pandas - To store in a dataframe, then excel
- json - To store as a JSON
Here is an example document, for which this script works well: https://www.canadapost.ca/assets/pdf/KB/nps/nps_nonlettermail_fsalist_jan2019.pdf
- Place the script in your preferred location
- Download the latest Canada Post listing of Forward Sortation Areas (FSAs)
- Run the python script, by navigating to the location and using 'python canada_fsa_parser.py' on your shell
- Provide the location when prompted. For ease of use, place the PDF in the same directory/folder and supply the full file name. Eg: 'nps_nonlettermail_fsalist_jan2019.pdf'
- The script will prompt you to save as an Excel or JSON, and make your selections
- The files should appear in the same directory as your script
- Voila!
Feel free to use the JSON text file or Excel file included in the files above