How to solve the following

Hi Bryan, I would adopt your suggestion for the csv file output, and thanks for your amazing help in answering my other questions too! Cheers