If your data source is a delimited file, take a look at (Gnu) AWK (it is part of every single Linux distro). Except the relational part of your examples, AWK can handle everything here in a blink of an eye. Of course, if your final destination is Excel anyway, you can save the roundtrip and just use Excel.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.