What the script does:

1. It strips empty lines and useless header stuff ("Exported from example.sch at 01-03-2021 15:34", "EAGLE Version 9.6.2 Copyright (c) 1988-2020 Autodesk, Inc.", etc) from the BOM file.

2. It saves this stripped information to a Tabbed text datafile (.tab extension)

3. It converts from a space/tab format to a normal CSV (comma separated text file for data. This file is then ready to import into Excel, Numbers or your other favorite spreadsheet. 

I have used the pandas library which is often used for machine learning / datascience for formatting the data to CSV format.

While you can expert the BOM as CSV directly from newer Eagle versions, you can't do the following through Eagle afaik:

4. It finally also generates a .sum.csv file with grouped parts (['Value', 'Device', 'Package']) and total numbers so you can easily see how many of each part you need for your PCB.

In case you are only interested in the .sum.csv, you can run the script with "onlytotals" argument: then the .tab and .csv intermediate files will be removed after processing. 

Hope you enjoy! :)

(Link to the Youtube channel of Stephen Hawes and his inspiring PnP machine project).