docs: def write_csv(data, file_name, encoding='utf-8'):
      '''
      Writes out to csv format.
  
      Args:
          data: 2D list of tables/worksheets.
          file_name: Name of the output file.
      '''
      name_extension = len(data) > 1
      root, ext = os.path.splitext(file_name)
  
      for i, sheet in enumerate(data):
          fname = file_name if not name_extension else root+"_"+str(i)+ext
          with open(fname, 'wb') as date_file:
              csv_file = csv.writer(date_file, encoding=encoding)
              for line in sheet:
                  csv_file.writerow(line)