I am certanly not a SSIS expert so I can't give you more details. Others on this forum might provide better help on that. But as far as I know you can create good conditional logic inside a SSIS package.
So instead of importing the CSV to a temp table and then analyse and process the lines you could try to analyse and proces the lines inside SSIS and then writing the results to the specific tables.
** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **