Want to generate csv of a view programmatically in drupal 7
Views data export


  This module is designed to provide a way to export large amounts of
  data from views. It provides a display plugin that can rendered
  progressively in a batch. Style plugins are included that support
  exporting in the following types:
  
  
  CSV 
  Microsoft XLS 
  Microsoft DOC 
  Basic TXT 
  XML
  


You should created a Views with CSV display. And then created a bottom that point to that page.