Hello Beuz1 and welcome to the board.

I don't think there is any pre-written code to do exactly what you're asking.

You would probably need to hand code it, but there are hundreds of UDF scripts that can help you to achieve your goals.

http://www.kixtart.org/udf/

Can you post some example data of your CSV (you can use dummy data) so that we can see what you've got so far and what you're trying to do.