First, we import the required libraries to handle argument parsing, creating counts of objects, parsing dates, writing XLSX spreadsheets, and our custom utilcsv module, which handles CSV reading and writing in this recipe:
from __future__ import print_functionimport argparsefrom collections import Counterfrom datetime import datetimeimport osimport sysfrom utility import utilcsvtry: import xlsxwriterexcept ImportError: print("[-] Install required third-party module xlsxwriter") sys.exit(1)
This recipe's command-line handler takes one positional argument: OUTPUT_DIR. This represents the desired output path for the XLSX file. Before calling the main() method, we check whether the output directory exists and create it if it does ...