only create csv file if there is data in table