Check out the attached macro.
It locates a bom feature.
Then it loops through each row and gets the components that make up that row.
I included some comments to try and get you on the correct path.
Edit... I've included a screen shot of the bom settings. You can parse the ItemNumber to know which level you are at in the bom in case you want a separate csv file for each bom.
ExportBOM.swp.zip 12.5 KB