Efficiency? Elegant Code? Nope but It works.
Luckily I did part 1 by looking at the symbols first anyway, so extending to part two was trivial. Also originally had a bug where I treated all symbols as cogs, not only '*'. Interestingly it worked anyway as only '*'s had two adjacent numbers in my data. It is fixed in this version.
Hacked together combined code (originally I did each part as separate programs but they shared so much that I ended up combining then so the post is shorter): https://pastebin.com/Dij2XSYe
Edit: anything in angle brackets is not displaying even with backslashes, idk why but i have moved the code to a pastebin.