This script will loop through all compound records in a .sd file, find the nitrogens in each compound, and identify the hybridization and bonding schemes for each N. If the nitrogen is primary or secondary, the script will add the appropriate number of methyl groups to convert it to a tertiary amine.
The script will discriminate between those functional groups that qualify as primary or secondary amines vs nitriles, amides, quaternary amines, etc.