hm......
shouldn't this be - missing single quote and F4 instead of F7:
SELECT *from where COLUMN1 in ( 'F1','F4','F7') and COLUMN2 in ('F2','F5','F6')"
And what's up with non-matching " at the tail end of the line?
You have plenty of similar threads in the past - including this one. None of the threads were neither marked "Solved" nor "thanked".
What you need to do is to transpose your input file (rows -> columns) in memory array AND "walk" the array creating your desired output.
P.S. and BTW, the C in CSV stands for "Comma" - you have no "Comma-Separated-Values" in your input file.